Skip to content
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

BUG: ExtensionIndex.map doesn't handle na_action correctly #32815

Closed
dsaxton opened this issue Mar 19, 2020 · 2 comments
Closed

BUG: ExtensionIndex.map doesn't handle na_action correctly #32815

dsaxton opened this issue Mar 19, 2020 · 2 comments
Labels
Bug ExtensionArray Extending pandas with custom dtypes or arrays.

Comments

@dsaxton
Copy link
Member

dsaxton commented Mar 19, 2020

(From master)

import pandas as pd

idx = pd.to_datetime(["2020-01-01", None])
idx.map(lambda x: pd.Timestamp("1999-01-01"), na_action="ignore")
# DatetimeIndex(['1999-01-01', '1999-01-01'], dtype='datetime64[ns]', freq=None)

idx = pd.CategoricalIndex(["a", None], categories=["a"])
idx.map(lambda x: x, na_action="ignore")
# TypeError: map() got an unexpected keyword argument 'na_action'

In the DatetimeIndex case idx.map should propagate the null value instead of returning Timestamp("1999-01-01") since na_action == "ignore", and although it isn't documented I think CategoricalIndex.map should allow na_action since the other map methods do.

@jbrockmendel jbrockmendel added the ExtensionArray Extending pandas with custom dtypes or arrays. label Sep 1, 2020
@mroeschke mroeschke added the Bug label Jul 30, 2021
@topper-123
Copy link
Contributor

The DateTimeIndex case has been fixed in #51936.

The Categorical case will be fixed when #51645 is merged.

@topper-123
Copy link
Contributor

#44279 is a duplicate of this, but it's specific to Categorical, which is the remaining case, so I'll close this issue and keep that open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug ExtensionArray Extending pandas with custom dtypes or arrays.
Projects
None yet
Development

No branches or pull requests

4 participants