@@ -8207,10 +8207,6 @@ def to_series(right):
8207
8207
level = level ,
8208
8208
)
8209
8209
right = left ._maybe_align_series_as_frame (right , axis )
8210
-
8211
- # Ensure attributes are consistent between the aligned and original objects
8212
- if right .attrs != getattr (other , "attrs" , {}):
8213
- right .attrs = getattr (other , "attrs" , {}).copy ()
8214
8210
return left , right
8215
8211
8216
8212
def _maybe_align_series_as_frame (self , series : Series , axis : AxisInt ):
@@ -8239,7 +8235,7 @@ def _maybe_align_series_as_frame(self, series: Series, axis: AxisInt):
8239
8235
index = self .index ,
8240
8236
columns = self .columns ,
8241
8237
dtype = rvalues .dtype ,
8242
- )
8238
+ ). __finalize__ ( series )
8243
8239
8244
8240
def _flex_arith_method (
8245
8241
self , other , op , * , axis : Axis = "columns" , level = None , fill_value = None
@@ -8285,13 +8281,13 @@ def _construct_result(self, result, other=None) -> DataFrame:
8285
8281
-------
8286
8282
DataFrame
8287
8283
"""
8288
- if not getattr (self , "attrs" , None ) and getattr (other , "attrs" , None ):
8289
- self .__finalize__ (other )
8290
8284
out = self ._constructor (result , copy = False ).__finalize__ (self )
8291
8285
# Pin columns instead of passing to constructor for compat with
8292
8286
# non-unique columns case
8293
8287
out .columns = self .columns
8294
8288
out .index = self .index
8289
+ if not getattr (self , "attrs" , None ) and getattr (other , "attrs" , None ):
8290
+ out = out .__finalize__ (other )
8295
8291
return out
8296
8292
8297
8293
def __divmod__ (self , other ) -> tuple [DataFrame , DataFrame ]:
0 commit comments