Which pandas function replaces the missing value by the value placed before the missing value?
Which pandas function replaces the missing value by the value placed before the missing value?
Solution
✅ Correct Option: 2
fillna(method='pad') is a forward fill. It carries the last valid value forward, so each missing value is replaced by the value placed just before it.
'pad' is an alias of 'ffill' (forward fill).
Option 1: 'bfill' is backward fill, which uses the next valid value after the missing one.
Options 3 and 4: 'nfill' and 'padded' are not valid fill methods in pandas.
Related questions:
2026: 11 May Shift 2
2025: 20 May Shift 1