Which statement distinguishes Series.map from DataFrame.apply in pandas?
Correct answer
C. map transforms each element; apply works row or column wise
14 views
C. map transforms each element; apply works row or column wise
14 views
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.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is C? Ask here and get an explanation.