Command
df.fillna
Explanation
df.fillna() replaces NaN values with specified values or methods.
Examples
Replace NaN with 0
df.fillna(0)
Forward fill missing values
df.fillna(method="ffill")
Backward fill missing values
df.fillna(method="bfill")
df.fillna
df.fillna() replaces NaN values with specified values or methods.
Replace NaN with 0
df.fillna(0)
Forward fill missing values
df.fillna(method="ffill")
Backward fill missing values
df.fillna(method="bfill")