The following function fills the missing values with next entry:
The following function fills the missing values with next entry:
Solution
✅ Correct Option: 1
bfill means backward fill. It fills each missing value (NaN) with the next valid value that appears after it in the column. For example, [1, NaN, NaN, 4] becomes [1, 4, 4, 4].
Option 2: pad is the same as ffill (forward fill). It copies the previous valid value forward, so it uses the previous entry, not the next.
Options 3 and 4: nullfill and null are not valid methods in pandas.
Memory trick: b = back (pull the next value backwards), f = forward (push the previous value forwards).
Related questions:
2026: 13 May Shift 2
2026: 23 May Shift 1
2026: 18 May Shift 2