Skip to content

DOC: Updated convert_dtype of Series.apply #39941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 25, 2021
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -4056,7 +4056,9 @@ def apply(
Python function or NumPy ufunc to apply.
convert_dtype : bool, default True
Try to find better dtype for elementwise function results. If
False, leave as dtype=object.
False, leave as dtype=object. Note that conversion does not
happen for extension array dtypes which have a map method
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
happen for extension array dtypes which have a map method
happen for extension array dtypes, such as Categorical.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are different behaviors for different extension array dtypes - using convert_dtype=False with Series([1], dtype=pd.Int64Dtype()) and Series([1], dtype="category") results in object and category dtypes respectively. Agreed on not mentioning the map method here, but it seems better to me to spell out which pandas dtypes will not come out as object when convert_dtype is False.

(e.g. Categorical).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete this line

args : tuple
Positional arguments passed to func after the series value.
**kwargs
Expand Down