Skip to content

The Value Error saying that empty data was passed with indices specif… #52084

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

Merged
merged 6 commits into from
Mar 20, 2023

Conversation

Xargonus
Copy link
Contributor

@Xargonus Xargonus commented Mar 20, 2023

…ied is now only raised when that is indeed the case.

The following example incorrectly triggers the ValueError saying that "Empty data passed with indices specified."

pd.DataFrame(np.zeros((0, 2)), columns=['a', 'b', 'c'])

…ied is now only raised when that is indeed the case.
Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for your pr

a few things:

  1. what would it show now instead? could you add a test please?
  2. why are you comparing an integer with a boolean?

@Xargonus
Copy link
Contributor Author

Hey, thank you for your quick response.

  1. The function still raises a ValueError, but no longer with an incorrect message. I am not sure if this needs to be tested.
  2. I am not comparing an integer with a boolean. I am doing chained comparison. a == b < c gets expanded to a == b and b < c.

@MarcoGorelli
Copy link
Member

MarcoGorelli commented Mar 20, 2023

I am not sure if this needs to be tested.

yup, definitely

I am doing chained comparison

ah I see, thanks

@MarcoGorelli
Copy link
Member

Nice, thanks! Can you add a whatsnew note to 2.1.0.rst too please?

@mroeschke mroeschke added the Error Reporting Incorrect or improved errors from pandas label Mar 20, 2023
Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there 💪

@@ -241,6 +241,7 @@ Styler
Other
^^^^^
- Bug in :func:`assert_almost_equal` now throwing assertion error for two unequal sets (:issue:`51727`)
- Bug in :func:`_check_values_indices_shape_match` no longer raises ValueError with a message saying that indices were specified when creating an empty DataFrame that has an issue with the number of columns in the data and in the columns argument.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to have an issue number (even if there's no issue, so here you can put the PR number, i.e. 52084)

Also, I think this would fit better in the "Other enhancements" section, as that's where some other error messages are?

Finally, the note needs to be user-facing and can't mention private methods. How about "Improved error message when creating DataFrame with empty data, no index, and wrong number of columns"?

@MarcoGorelli MarcoGorelli added this to the 2.1 milestone Mar 20, 2023
… the visible behavior for the library user instead of the behavior of a private method.
Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me pending green, thanks @Xargonus

@mroeschke mroeschke merged commit 532ed6f into pandas-dev:main Mar 20, 2023
@mroeschke
Copy link
Member

Thanks @Xargonus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants