1. Home
  2. Data Science
  3. Pandas
  4. What does Series.map(func, na_action='ignore') change…

Added 30 Nov -0001

What does Series.map(func, na_action='ignore') change compared with the default behaviour?

  1. NaN entries are replaced by whatever the function happens to return for a NaN
  2. NaN entries pass through untouched instead of being sent to the function Correct answer
  3. NaN entries raise an error rather than being silently forwarded to func
  4. The mapping dictionary's NaN key is used, overriding any default value

Correct answer

B. NaN entries pass through untouched instead of being sent to the function

16 views

MCQSEXAM

Explanation

By default map calls the function on every entry, including NaN, which is why a function that cannot handle missing values fails; na_action='ignore' skips those entries and leaves them as NaN. The option applies to a callable, not to a dict mapping, where a missing key already becomes NaN. Use fillna or a mapping with an explicit default to control the replacement.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Pandas MCQs

Practise all Pandas MCQs

Similar MCQs