PANDAS: Can I fill NAN values in just one column of my dataframe?

0

I have a dataframe of 3 columns all numeric. Within the data there are missing values NAN and I have no problems in filling them with fillna(method=pad) all except NAN of the first column that require fillna(mean()) . Is there a way to fill NAN by column to use different methods?

    
asked by Luis Pazos 04.08.2017 в 21:47
source

1 answer

0

In this way the nan process in the first column.

df.loc[:,'time'] =df.loc[:,'time'].fillna(df.loc[:,'time'].mean())

In this way the nan process of the rest of the columns.

df.loc[:,'gold':'silver'] = df.loc[:,'gold':'silver'].fillna(method='pad')

I found the solution >:)

    
answered by 04.08.2017 / 22:31
source