Conversation

Xargonus

…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.

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

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

I am not sure if this needs to be tested.

yup, definitely

I am doing chained comparison

ah I see, thanks

@MarcoGorelli

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

@mroeschkemroeschke added the Error ReportingIncorrect or improved errors from pandaslabel Mar 20, 2023

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"?

@MarcoGorelliMarcoGorelli 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.

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

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

Thanks @Xargonus

Sign up for free to join this conversation on . Already have an account? Sign in to comment
Error ReportingIncorrect or improved errors from pandas
None yet

Successfully merging this pull request may close these issues.