Series.apply()Map values of Series using input correspondence (which can be a dict, Series, or function)
Invoke function on values of Series. Can be ufunc (a NumPy function that applies to the entire Series) or a Python function that only works on single values
apply()
seems like it does mostly everything map()
does, vectorizing scalar functions while applying vectorized operations as they are. Meanwhile map()
allows for some amount of control over null value handling. Apart from historical analogy to Python's apply()
and map()
functions, is there a reason to prefer one over the other in general use? Why wouldn't these functions just be combined?