Pandas Series: apply() function

Invoke a python function on values of Pandas series

The apply() function is used to invoke a python function on values of Series.


Series.apply(self, func, convert_dtype=True, args=(), **kwds)
Pandas Series apply image


Name Description Type/Default Value Required / Optional
func Python function or NumPy ufunc to apply. function Required
convert_dtype Try to find better dtype for elementwise function results. If False, leave as dtype=object. bool
Default Value: True
args Positional arguments passed to func after the series value. tuple Required
**kwds Additional keyword arguments passed to func.   Required

Returns: Series or DataFrame
If func returns a Series object the result will be a DataFrame.


Download the above Notebook from here.

Previous: Compute the dot product between the Series and the columns in Pandas
Next: Aggregation in Pandas