replace nan values with mean pandas code example
Example 1: replace nan in pandas
df['DataFrame Column'] = df['DataFrame Column'].fillna(0)
Example 2: how to fill nas on a dataframe with median
df.fillna(df.mean(), inplace=True)
Example 3: python fillna with mean in a dataframe
df["newColumName"] = df["originalColumnName"].fillna(df["originalColumnName"].mean())
Example 4: replace error with nan pandas
df['workclass'].replace('?', np.NaN)