Which function do we use to fill the missing values with previous entry?
Which function do we use to fill the missing values with previous entry?
Solution
✅ Correct Option: 2
.fillna(method='pad') is the pandas forward-fill. It replaces each missing value (NaN) with the previous non-null entry in the same column. 'pad' is an alias of 'ffill'.
Option 3: 'bfill' is backward fill. It uses the next valid entry, not the previous one.
Options 1 and 4: .dropna() removes rows with missing values instead of filling them. how='all' drops only rows where every value is NaN.
In newer pandas versions, method= in fillna is deprecated, and .ffill() is preferred.
Related questions:
2026: 23 May Shift 1
2026: 24 May Shift 1