-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
Fix binary operations on attrs for Series and DataFrame #59636
base: main
Are you sure you want to change the base?
Conversation
fbourgey
commented
Aug 28, 2024
- closes BUG: binary operations don't propogate attrs depending on order with Series and/or DataFrame/Series #51607
- Test
- Test
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.
Small change to prefer fixtures to writing out our own binop implementations, but generally lgtm. I don't think current CI failures are related.
@mroeschke any thoughts here?
pandas/tests/frame/test_api.py
Outdated
df_2 = DataFrame({"A": [-3, 9]}) | ||
attrs = {"info": "DataFrame"} | ||
df_1.attrs = attrs | ||
assert (df_1 + df_2).attrs == attrs |
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.
Rather than doing this you can just use the all_binary_operators
fixture from conftest.py (I think)
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.
I made the change.
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.
I think attrs propagation logic should should only be handled by __finalize__
, so these binary operations should dispatch to that method
@mroeschke should everything be rewritten using |
Yes, or |
This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this. |
@mroeschke, @WillAyd, I tried using |
I think it looks good but will defer to @mroeschke |
I don't think the CI failures are related. This still lgtm - @mroeschke can you take another look? |