df.fillna(df.mean())
# axis=1 means fillna by rows
df = df.fillna(axis=1, method='backfill')
df = df.fillna(axis=1, method='ffill')
# methods
# pad / ffill: propagate last valid observation forward to next valid.
# backfill / bfill: use next valid observation to fill gap.
For one column using pandas:
df['DataFrame Column'] = df['DataFrame Column'].fillna(0)
--fillna
product_mean = df['product'].mean()
df['product'] = df['product'].fillna(product_mean)
--replace method
col_mean = np.mean(df['col'])
df['col'] = df['col'].replace(np.nan, col_mean)
df['Item_Weight'] = df['Item_Weight'].fillna((df['Item_Weight'].mean()))
#fill nan values with mean
df = df.fillna(df.mean())
# Try using a loc instead of a where:
df_sub = df.loc[df.yourcolumn == 'yourvalue']
df['Column_Name'].fillna(df['Column_Name'].mode()[0], inplace=True)
#fill nan values with mean
df = df.fillna(df.mean())