-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
BUG: fix convert_dtypes to handle empty df #40402
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
BUG: fix convert_dtypes to handle empty df #40402
Conversation
Added a conditional to check a DataFrame had at least one column and if not return the original (empty) DataFrame if so.
Added unit test and added reference to whatsnew
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 PR!
Just a few small comments
Moved a frame test incorrectly placed in the series hierarchy. Fixed some naming in bug documentation. Changed convert_dtypes to return a copy of apparently empty dataframes
Thanks @jorisvandenbossche All good call outs (particularly the test in the wrong place - I should've noticed that). I hope it looks better now. |
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 really good - two minor requests
Changed test to use tm.assert_equal and documented error more explicitly
Thanks for the feedback @rhshadrach I'm still not sure I've got the assert written the way you'd like - didn't know whether to compare the DataFrame to itself or to a new empty DataFrame. Please let me know if you'd like anything else updated. |
Replaced tm.assert_equals with tm.assert_frame_equals
Thanks a lot @owenlamont for your first contribution! |
Thank you! I'm honoured to contribute to such a foundational part of the PyData ecosystem. First of many hopefully. |
Added a conditional to check a DataFrame had at least one column and if not return the original (empty) DataFrame if so.