Skip to content

BUG: Categorical of booleans has object .categories #46422

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 5 commits into from
Mar 20, 2022

Conversation

rxd330
Copy link
Contributor

@rxd330 rxd330 commented Mar 18, 2022

This patch adds a test for checking regression behavior as described in #46313. The bug was reported to be fixed and I could not reproduce the bug in the latest version as Mar.18, 2022. So, only a test was added.

This is my first contribution to the open-source project. Please let me know if something needs to be fixed. Thanks!

@jreback jreback changed the title Test for gh46313 BUG: Categorical of booleans has object .categories Mar 19, 2022
@jreback jreback added Dtype Conversions Unexpected or buggy dtype conversions Categorical Categorical Data Type labels Mar 19, 2022
@jreback jreback added this to the 1.5 milestone Mar 19, 2022
@jreback jreback added the Testing pandas testing functions or related to the test suite label Mar 19, 2022
)
value = df["bool_cat"].cat.categories.dtype
expected = np.dtype(np.bool_)
not_expected = np.dtype(np.object_)
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need the not expected case

def test_categorical_of_booleans_is_boolean():
# https://github.com/pandas-dev/pandas/issues/46313
df = pd.DataFrame(
{"int_cat": [1, 2, 3], "bool_cat": [True, False, False]}, dtype="category"
Copy link
Contributor

Choose a reason for hiding this comment

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

move to pandas/tests/series/accessors/test_cat_accessor.py

@rxd330
Copy link
Contributor Author

rxd330 commented Mar 20, 2022

Hi there, I moved the code to the specified location and removed the unnecessary line.

Thanks for giving feedback!

@rxd330 rxd330 requested a review from jreback March 20, 2022 15:41
@mroeschke mroeschke merged commit 6033ed4 into pandas-dev:main Mar 20, 2022
@mroeschke
Copy link
Member

Thanks @rxd330

yehoshuadimarsky pushed a commit to yehoshuadimarsky/pandas that referenced this pull request Jul 13, 2022
* TST: tests added pre GH46313

* Revert "TST: tests added pre GH46313"

This reverts commit a5a0a29.

* TST:test added for GH46313

* file reformated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Categorical Categorical Data Type Dtype Conversions Unexpected or buggy dtype conversions Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Categorical of booleans has object .categories
3 participants