-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Test that nan value counts are included when dropna=False. GH#31944 #36783
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
Test that nan value counts are included when dropna=False. GH#31944 #36783
Conversation
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 @icanhazcodeplz for the PR!
Some comments
@@ -274,3 +274,12 @@ def test_value_counts_datetime64(index_or_series): | |||
td2 = klass(td2, name="dt") | |||
result2 = td2.value_counts() | |||
tm.assert_series_equal(result2, expected_s) | |||
|
|||
|
|||
def test_value_counts_nan(index_or_series): |
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.
I'd call it test_value_counts_with_nan
def test_value_counts_nan(index_or_series): | ||
"""Test that nan value counts are included when dropna=False. GH#31944""" | ||
klass = index_or_series | ||
s_values = [True, pd.NA, np.nan] |
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.
call this data
or values
s_values = [True, pd.NA, np.nan] | ||
s = klass(s_values) | ||
expected = Series([2, 1], index=[pd.NA, True]) | ||
tm.assert_series_equal(s.value_counts(dropna=False), expected) |
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.
you wanna define res = s.value_counts(dropna=False)
and then tm.assert_series_equal(res, expected)
|
||
|
||
def test_value_counts_nan(index_or_series): | ||
"""Test that nan value counts are included when dropna=False. GH#31944""" |
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.
# GH31944
is enough here
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.
lgtm
one nit pick. Also could you parametrize on dropna (True/False) - I assume we don't test it or we should have been testing dropna=False too
klass = index_or_series | ||
values = [True, pd.NA, np.nan] | ||
s = klass(values) | ||
expected = Series([2, 1], index=[pd.NA, True]) |
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.
nit-pick: can you move this to after res
That way this reads: construct result, construct expected result, compare result with expected
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.
Sure, makes sense!
Hi y'all, any other changes for this pull request? |
thanks @icanhazcodeplz |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
Added test per @Dr-Irv request.