1. Home
  2. Data Science
  3. Pandas
  4. Which statement distinguishes Series.map from…

Added 30 Nov -0001

Which statement distinguishes Series.map from DataFrame.apply in pandas?

  1. Both are identical when applied to any DataFrame or Series object
  2. map only accepts NumPy ufuncs, never functions
  3. map transforms each element; apply works row or column wise Correct answer
  4. map works row wise; apply transforms each element

Correct answer

C. map transforms each element; apply works row or column wise

14 views

MCQSEXAM

Explanation

Series.map applies a function or a dictionary mapping element by element and returns a Series of the same length, which suits recoding categories. DataFrame.apply passes an entire row or column at a time, defaulting to columns, and is used when a calculation needs several fields together. Both are Python-level loops under the hood and are slower than vectorised operations such as np.where or pandas' string methods.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is C? 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