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)
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
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework