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

@mroeschke
Copy link
Member

Yes, or __finalize__ needs to be probably be called somewhere

Copy link
Contributor

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.

@github-actions github-actions bot added the Stale label Nov 29, 2024
@fbourgey
Copy link
Contributor Author

fbourgey commented Dec 2, 2024

@mroeschke, @WillAyd, I tried using __finalize__ instead. What do you think?

@WillAyd WillAyd removed the Stale label Dec 3, 2024
@WillAyd
Copy link
Member

WillAyd commented Dec 3, 2024

I think it looks good but will defer to @mroeschke

@WillAyd
Copy link
Member

WillAyd commented Feb 3, 2025

I don't think the CI failures are related. This still lgtm - @mroeschke can you take another look?

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