-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Show column name in assert_frame_equal #29218
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
ENH: Show column name in assert_frame_equal #29218
Conversation
The output of the AssertionError is changed: - old: `AssertionError: Attributes of DataFrame.iloc[:, 1] are different` - new: `AssertionError: Attributes of DataFrame.loc[:, 'b'] are different`
hmm, the only issue is this doesn't quite work for duplicated names, but i guess this is friendlier for readers of the error message. |
Yeah duplicates labels was my initial concern. Can we update the error message to keep using |
Thanks for the feedback! |
Sorry for the multiple commits. Feel free to squash. |
@moi90 no need to worry about the squashing, but we do need to get the tests passing. looks like there are a handful of places where you need to update the expected error message |
I will look into this. |
@moi90 any luck? If you have questions feel free to post them on there :) |
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 good to me. Optional comment from my perspective
pandas/util/testing.py
Outdated
@@ -1400,7 +1400,9 @@ def assert_frame_equal( | |||
check_names=check_names, | |||
check_datetimelike_compat=check_datetimelike_compat, | |||
check_categorical=check_categorical, | |||
obj="{obj}.iloc[:, {idx}]".format(obj=obj, idx=i), | |||
obj='{obj}.iloc[:, {idx}] (column name="{col}")'.format( |
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.
If you wanted to could just use f-strings to make this even more compact
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.
They are new in 3.6. Is anything older not supported anymore by pandas?
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.
no we just dropped 3.5
@moi90 if you can use f-strings and ping on green. |
@moi90 can you rebase |
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 looks close. Looks like maybe an issue on previous conflict fix ups; if you can resolve and repush would be great!
pandas/util/testing.py
Outdated
|
||
return wrapper | ||
|
||
|
||
with_connectivity_check = network | ||
|
||
|
||
def assert_raises_regex(_exception, _regexp, _callable=None, *args, **kwargs): |
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 was removed in #29174 so want to be careful not to add back in here
the CI error in the linter usually means there is an unused import somehwere |
No, it's an error in flake8:
I'm beginning to give up... Can't someone of the core team bring it to a successful conclusion? |
The last few times I've seen this, it turned out there was an unused import somewhere. |
can you merge master |
@moi90 I merged master and fixed some flake8 issues. Not sure why it failed before, but know that you can always run the linting checks locally (I recommend installing git commit hooks for this: https://dev.pandas.io/docs/development/contributing.html#python-pep8-black). All green now, so will merge. Thanks for the PR! |
Wonderful, thanks! And you're welcome :) |
The output of the AssertionError raised by assert_frame_equal is changed:
old:
AssertionError: Attributes of DataFrame.iloc[:, 1] are different
new:
AssertionError: Attributes of DataFrame.loc[:, 'b'] are different
closes #xxxx
tests added / passed
passes
black pandas
passes
git diff upstream/master -u -- "*.py" | flake8 --diff
whatsnew entry