I have data for many countries over a period of time (2001-2003). It looks something like this:
index | year | country | inflation | GDP |
---|---|---|---|---|
1 | 2001 | AFG | nan | 48 |
2 | 2002 | AFG | nan | 49 |
3 | 2003 | AFG | nan | 50 |
4 | 2001 | CHI | 3.0 | nan |
5 | 2002 | CHI | 5.0 | nan |
6 | 2003 | CHI | 7.0 | nan |
7 | 2001 | USA | nan | 220 |
8 | 2002 | USA | 4.0 | 250 |
9 | 2003 | USA | 2.5 | 280 |
I want to drop countries in case there is no data (i.e. values are missing for all years) for any given variable.
In the example table above, I want to drop AFG (because it misses all values for inflation) and CHI (GDP missing). I don't want to drop observation #7 just because one year is missing.
What's the best way to do that?