-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
TEST: Add test for select_dtypes on an empty DataFrame #62359
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
Conversation
3e19eeb to
59712b5
Compare
simonjayhawkins
left a comment
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 @deepith-18 for the PR
CI is failing.
| If 0 or 'index' counts are generated for each column. | ||
| If 1 or 'columns' counts are generated for each row. | ||
| numeric_only : bool, default False | ||
| numeric_only : bool, default False. |
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.
this needs to be reverted?
| result.iloc[0, 0] = 0 | ||
| tm.assert_frame_equal(df, df_orig) | ||
|
|
||
| def test_select_dtypes_empty_frame(): |
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.
please explain why this test is needed. I assume you have identified a gap in the testing, perhaps using code coverage tools or found an reported issue on the pandas issue tracker which is fixed on main and labelled Needs Tests to prevent regression?
A separate test is usually added at the end of the file when adding a regression test with a link to a known issue.
For general testing, the input dataframe could be added to the parameterisation used in the existing tests.
Or if having a dedicated test for an empty DataFrame, we would probably also want to test more than just the str type representation of a single dtype to include. For full coverage, we would want to test more dtypes, list like of dtypes and the same for the exclude parameter?
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 the detailed review and guidance, @simonjayhawkins! I will revert the change in frame.py.
My apologies for adding a separate test function. I'm new to the testing suite and your suggestion to add the empty DataFrame to the existing parameterized tests makes a lot of sense. I will work on that now.
in that case, maybe better to, in the first instance, have a go at addressing an open issue that is tagged Needs Tests and Good First Issue. I'll close this PR for now. |
This PR adds a new test to verify the behavior of
DataFrame.select_dtypeswhen called on an empty DataFrame.The test confirms that the function correctly returns an empty DataFrame with the original index, which is the expected behavior.