Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
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 Pandas Series Notebooks from here.

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