I tried a couple methods to clean rows containing NaN
from a particular Series in my DataFrame only to realize every NaN
entry is a 'NaN'
string, not a null value.
In my specific example, each row represents a country and so I want to remove all countries that do not have a GDP value in the 'GDP per Capita'
column from the DataFrame.
Some things I tried (that failed):
df_noGDP = df
df_noGDP.dropna(axis=0, subset=['GDP per Capita'])
and
df_noGDP = df.loc[df['GDP per Capita'] != np.nan]
When I call df_noGDP
, I see that no NaN
values are removed. I figure I'm either making a silly syntax error somewhere or I need to convert my data types.