Reputation: 85
I have this dataframe
My goal is to fill the Nan values in the 3rd and 4th column with the non-Nan data in each column. Tried shift(-5) but didn't get it to work. Any thoughts?
Upvotes: 0
Views: 35
Reputation: 34046
Use bfill
:
df[['col3','col4']] = df[['col3','col4']].bfill()
OR:
df[['col3','col4']] = df[['col3','col4']].fillna(method='bfill')
Upvotes: 1