-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Fix binary operations on attrs for Series and DataFrame #59636
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
Changes from 1 commit
38efbaa
15db834
50118d7
953ef17
bc4da65
2607f9c
b154203
87abede
8559c1f
742e3b1
5178113
5b71171
8da62bd
c2c87dd
4da1786
6436926
50396ad
76b0831
ef3c0b5
e92e431
311b662
95cb745
c162bba
bd46491
bf898c7
e9c3e91
b72a049
3abc22d
1e6197c
3a80cf9
83e908f
e342a6e
c251196
96ddd0d
155a9d1
45e2ad0
cf67fcf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -8088,8 +8088,7 @@ def _align_for_op( | |||||||
|
||||||||
Parameters | ||||||||
---------- | ||||||||
left : DataFrame | ||||||||
right : Any | ||||||||
other : Any | ||||||||
axis : int | ||||||||
flex : bool or None, default False | ||||||||
Whether this is a flex op, in which case we reindex. | ||||||||
|
@@ -8101,8 +8100,6 @@ def _align_for_op( | |||||||
left : DataFrame | ||||||||
right : Any | ||||||||
""" | ||||||||
if not getattr(self, "attrs", None) and getattr(other, "attrs", None): | ||||||||
self.__finalize__(other) | ||||||||
|
||||||||
left, right = self, other | ||||||||
|
||||||||
|
@@ -8203,7 +8200,6 @@ def to_series(right): | |||||||
"`left, right = left.align(right, axis=1)` " | ||||||||
"before operating." | ||||||||
) | ||||||||
|
||||||||
left, right = left.align( | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
right, | ||||||||
join="outer", | ||||||||
|
@@ -8212,6 +8208,9 @@ def to_series(right): | |||||||
) | ||||||||
right = left._maybe_align_series_as_frame(right, axis) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this resets the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would consider that a bug. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should I fix it in this PR or raise a different issue? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can fix it in this PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggested something below |
||||||||
|
||||||||
# Ensure attributes are consistent between the aligned and original objects | ||||||||
if right.attrs != getattr(other, "attrs", {}): | ||||||||
right.attrs = getattr(other, "attrs", {}).copy() | ||||||||
return left, right | ||||||||
|
||||||||
def _maybe_align_series_as_frame(self, series: Series, axis: AxisInt): | ||||||||
|
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.