-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Fixed bug, where pandas._libs.lib.maybe_convert_objects function improperly handled arrays with bools and NaNs #32242
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 all commits
8709bb2
de4cffd
a47fb2d
b69c69e
d8bd31e
a2294ca
28ef7dd
51f5b4f
893cbf7
76d60cd
839168b
8a1b8ca
a37c254
e43fd8d
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import numpy as np | ||
import pytest | ||
|
||
import pandas as pd | ||
from pandas import Categorical, CategoricalIndex, Series | ||
|
@@ -177,3 +178,28 @@ def test_value_counts_categorical_with_nan(self): | |
exp = Series([2, 1, 3], index=CategoricalIndex(["a", "b", np.nan])) | ||
res = ser.value_counts(dropna=False, sort=False) | ||
tm.assert_series_equal(res, exp) | ||
|
||
@pytest.mark.parametrize( | ||
"ser, dropna, exp", | ||
[ | ||
( | ||
pd.Series([False, True, True, pd.NA]), | ||
False, | ||
pd.Series([2, 1, 1], index=[True, False, pd.NA]), | ||
), | ||
( | ||
pd.Series([False, True, True, pd.NA]), | ||
True, | ||
pd.Series([2, 1], index=[True, False]), | ||
), | ||
( | ||
pd.Series(range(3), index=[True, False, np.nan]).index, | ||
False, | ||
pd.Series([1, 1, 1], index=[True, False, pd.NA]), | ||
), | ||
], | ||
) | ||
def test_value_counts_bool_with_nan(self, ser, dropna, exp): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I may have misunderstood the original issue, but my understanding is that the values were correct, just the repr was wrong. If so, why are we adding new tests here, which I think don't cover the reported issue? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I see it was requested by @jreback in https://github.com/pandas-dev/pandas/pull/32242/files#r385098106. I suppose no harm in more tests, but don't we think this is already tested? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @TomAugspurger Yes, I agree that this has been tested. Was following the suggestion of @jreback. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jreback can you comment on the request / need for these tests? |
||
# GH32146 | ||
out = ser.value_counts(dropna=dropna) | ||
tm.assert_series_equal(out, exp) |
Uh oh!
There was an error while loading. Please reload this page.