xxxxxxxxxx
df['Column_Name'].fillna(df['Column_Name'].mode()[0], inplace=True)
xxxxxxxxxx
import pandas as pd
# Assuming 'df' is the pandas DataFrame
# Fill NaN values with a specific value, 0 in this case
df.fillna(0, inplace=True)
# Fill NaN values with the mean of the column
df.fillna(df.mean(), inplace=True)
# Fill NaN values with the forward fill method
df.fillna(method='ffill', inplace=True)
# Fill NaN values with the backward fill method
df.fillna(method='bfill', inplace=True)
xxxxxxxxxx
For one column using pandas:
df['DataFrame Column'] = df['DataFrame Column'].fillna(0)