-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST: add test to check dtype after replacing values in categorical Series inplace #53993
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
TST: add test to check dtype after replacing values in categorical Series inplace #53993
Conversation
@mroeschke, I added a test to check if the |
result = pd.Series(data, dtype="category") | ||
result.replace(to_replace="a", value="b", inplace=True) | ||
expected = pd.Series(data_exp, dtype="category") | ||
tm.assert_index_equal(expected.dtype.categories, result.dtype.categories) |
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.
Is this not covered by tm.assert_series_equal?
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.
Yes, tm.assert_series_equal(result, expected)
should be sufficient
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.
Thank you, I replaced tm.assert_index_equal
with tm.assert_series_equal
.
Thanks @natmokval |
…ries inplace (pandas-dev#53993) * TST: add test to check dtype after replacing categorical Series inplace * replace tm.assert_index_equal with tm.assert_series_equal
closes BUG:
Series.replace
doesn't updateCategoricalDtype
wheninplace=True
in pandas-2.0 #53358added a test in order to check if the
dtype
is being updated, when we replace values in a categorical Series withinplace=True
.