-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
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
Changes from all commits
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 |
---|---|---|
|
@@ -483,3 +483,10 @@ def test_select_dtypes_no_view(self): | |
result = df.select_dtypes(include=["number"]) | ||
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 commentThe 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 commentThe 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. |
||
# Test that select_dtypes works on a completely empty DataFrame | ||
df = DataFrame() | ||
result = df.select_dtypes(include="int64") | ||
expected = DataFrame() | ||
tm.assert_frame_equal(result, 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.
this needs to be reverted?