Skip to content

Fixed regression in Series.duplicated for categorical dtype with bool categories #44356

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 3 commits into from
Nov 12, 2021

Conversation

phofl
Copy link
Member

@phofl phofl commented Nov 8, 2021

@phofl phofl added Categorical Categorical Data Type Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Regression Functionality that used to work in a prior pandas version labels Nov 8, 2021
@phofl phofl added this to the 1.3.5 milestone Nov 8, 2021
Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

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

Thanks @phofl Generally LGTM.

I think could maybe also mention drop_duplicates in the release note, but probably don't need extra tests.

However, the code sample in the issue OP is based on test_drop_duplicates_categorical_bool in pandas/tests/series/methods/test_drop_duplicates.py so could make sense to co-locate the tests and also test for drop_duplicates

@phofl
Copy link
Member Author

phofl commented Nov 9, 2021

Added the test and modified the release note

)
result = ser.drop_duplicates()
expected = Series(
Categorical([True, False, np.nan], categories=[True, False], ordered=True),
Copy link
Contributor

Choose a reason for hiding this comment

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

this might be a bug as this is not preserving NA (but unrelated / not a regression, so pls open a new issue)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, #44405

Copy link
Member

Choose a reason for hiding this comment

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

The test case is actually a bit misleading. This regression was just about a boolean categorical with missing values, not specifically with NA (also if you create the data with np.nan, you had the same issue)

@jreback jreback merged commit 9f54f70 into pandas-dev:master Nov 12, 2021
@jreback
Copy link
Contributor

jreback commented Nov 12, 2021

@meeseeksdev backport 1.3.x

@jreback
Copy link
Contributor

jreback commented Nov 12, 2021

thanks @phofl

@lumberbot-app

This comment has been minimized.

@lumberbot-app

This comment has been minimized.

phofl added a commit to phofl/pandas that referenced this pull request Nov 12, 2021
@phofl phofl deleted the 44351_new branch November 12, 2021 08:33
simonjayhawkins pushed a commit that referenced this pull request Nov 12, 2021
nickleus27 pushed a commit to nickleus27/pandas that referenced this pull request Nov 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Categorical Categorical Data Type Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

REGR: Series.duplicated with category dtype and nulls raises ValueError
4 participants