Reputation: 73
I have a DataFrame 'df'
And the second is 'nan_gdp'
How can I fill NaN gdp in 'nan_gdp' by using my first DataFrame 'df'. Also, in the first df I dont have all countries, it means that there are some countries which are in 'nan_gdp' but not in 'df'
Upvotes: 1
Views: 210
Reputation: 863216
Use Series.fillna
by mapped values from df
by Series.map
:
s = df.set_index('Country')['GDP ($M)']
waste['GDP ($M)'] = waste['GDP ($M)'].fillna(waste['Country'].map(s))
Upvotes: 1