Skip to main contentSkip to solution

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).

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question