60-second card
Missing values
Missing values show up as NaN. Find them, then drop or fill them.
- df.isna().sum() counts missing values per column.
- df.dropna() removes rows with any missing value.
- df['marks'].fillna(0) or fillna(df['marks'].mean()) fills the gaps.
import pandas as pd
import numpy as np
s = pd.Series([80, np.nan, 90])
print(int(s.isna().sum()), s.fillna(s.mean()).tolist())Prints
1 [80.0, 85.0, 90.0]Remember: Count missing values before you decide what to do.
Common mistake: Filling everything with 0 without thinking. 0 marks and 'unknown' aren't the same.