Skip to content
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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

Copy link
Member

@WillAyd WillAyd left a 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?

df_2 = DataFrame({"A": [-3, 9]})
attrs = {"info": "DataFrame"}
df_1.attrs = attrs
assert (df_1 + df_2).attrs == attrs
Copy link
Member

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made the change.

Copy link
Member

@mroeschke mroeschke left a 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 mroeschke added metadata _metadata, .attrs Numeric Operations Arithmetic, Comparison, and Logical operations labels Sep 25, 2024
@fbourgey
Copy link
Contributor Author

@mroeschke should everything be rewritten using finalize then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
metadata _metadata, .attrs Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: binary operations don't propogate attrs depending on order with Series and/or DataFrame/Series
3 participants