how to fill nan with mean in pandas code example
Example 1: how to fill nan values with mean in pandas
df.fillna(df.mean())
Example 2: pandas where retuning NaN
# Try using a loc instead of a where:
df_sub = df.loc[df.yourcolumn == 'yourvalue']
df.fillna(df.mean())
# Try using a loc instead of a where:
df_sub = df.loc[df.yourcolumn == 'yourvalue']