-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
BUG: Fix Categorical displays string categories without quotes when dtype is "string" #63070
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
Changes from 2 commits
7bc3b08
f69cfe6
37f2867
8f84512
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -545,3 +545,11 @@ def test_categorical_str_repr(self): | |||||||||||||
| result = repr(Categorical([1, "2", 3, 4])) | ||||||||||||||
| expected = "[1, '2', 3, 4]\nCategories (4, object): [1, 3, 4, '2']" | ||||||||||||||
| assert result == expected | ||||||||||||||
|
|
||||||||||||||
| def test_categorical_with_pandas_series(self): | ||||||||||||||
|
||||||||||||||
| def test_categorical_with_pandas_series(self): | |
| def test_categorical_with_string_dtype(self): |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| def test_categorical_with_pandas_series(self): | |
| # GH 63045 | |
| s = Series(["apple", "banana", "cherry", "cherry"], dtype="string") | |
| def test_categorical_with_pandas_series(self, string_dtype_no_object): | |
| # GH 63045 | |
| s = Series(["apple", "banana", "cherry", "cherry"], dtype=string_dtype_no_object) |
You could maybe use here this fixture that will test it for the different string dtype variations, to make sure we now do this consistently for all string like dtypes.
The only thing you will have to update is the "string" in the expected result below (you can include str(string_dtype_no_object) in the expected value)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your review. I have updated this test accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not so much the issue that the Categorical was created from a Series, but that it is using the
stringdtype for its categories (you can construct the same categorical in other ways as well)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your review. I have updated this doc accordingly.