-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Add dropna argument to DataFrame.value_counts() #41334
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
ENH: Add dropna argument to DataFrame.value_counts() #41334
Conversation
connesy
commented
May 5, 2021
- closes ENH: Add dropna argument to pd.DataFrame.value_counts() #41325
- tests added / passed
- Ensure all linting tests pass, see here for how to run them
- whatsnew entry
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.
looks good, small comments
@@ -100,3 +100,47 @@ def test_data_frame_value_counts_empty_normalize(): | |||
expected = pd.Series([], dtype=np.float64) | |||
|
|||
tm.assert_series_equal(result, expected) | |||
|
|||
|
|||
def test_data_frame_value_counts_dropna_true(nulls_fixture): |
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 it possible to parameterize this test with dropna
instead of 2 separate tests?
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 am not sure how to do that while using the nulls_fixture
. Any suggestion is welcome!
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 can simply add another parametrization:
@pytest.mark.parametrize("x", [1, 2])
def test_data_frame_value_counts_dropna_true(nulls_fixture, x):
pass
But I don't know if this wouldn't make it more complicated 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.
The issue is that the input and expected dataframes are quite different in the two tests, so they would need to be defined as part of the parametrization. But both are also defined using the values from the nulls_fixture
, so I would somehow need to use the fixture values in the parametrization, and I'm not sure how I can do both.
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.
Ah now I get it. if else is the only way here, but I think this would make it more complicated than is worth
Two of the builds failed due to tests that I have not touched. It seems like those tests fail quite often? |
thanks @connesy very nice That CI build fails occasionaly and is unrelated here, so all good. |