w3resource

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.

Syntax:

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

Parameters:

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
Required
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.

Example:


Download the above Notebook from here.



Inviting useful, relevant, well-written and unique guest posts