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

REGR: missing vals not replaceable in categorical #40657

Closed

Conversation

mzeitlin11
Copy link
Member

This restores behavior to before the regression, but I think also deprecating this behavior while patching might be reasonable. Since categoricals represent all missing values the same way, this allows unintuitive behavior like

ser = pd.Series([None, "b"]).astype('category')
ser = ser.replace({np.nan: 'c'})
print(ser)

replacing the missing value even though None and np.nan are different missing values. Forcing usage of the more explicit fillna seems more reasonable in this case.

@pep8speaks
Copy link

pep8speaks commented Mar 27, 2021

Hello @mzeitlin11! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-03-27 17:07:49 UTC

@mzeitlin11 mzeitlin11 added Categorical Categorical Data Type Regression Functionality that used to work in a prior pandas version replace replace method labels Mar 27, 2021
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

this is a special case: #40472 (comment)

let's discuss first

@mzeitlin11
Copy link
Member Author

Ah makes sense, will close until discussion resolved

@mzeitlin11 mzeitlin11 closed this Mar 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Categorical Categorical Data Type Regression Functionality that used to work in a prior pandas version replace replace method
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: series.replace(np.nan,..) on categorical series does not replace
3 participants