@@ -8207,10 +8207,6 @@ def to_series(right):
82078207 level = level ,
82088208 )
82098209 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 ()
82148210 return left , right
82158211
82168212 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):
82398235 index = self .index ,
82408236 columns = self .columns ,
82418237 dtype = rvalues .dtype ,
8242- )
8238+ ). __finalize__ ( series )
82438239
82448240 def _flex_arith_method (
82458241 self , other , op , * , axis : Axis = "columns" , level = None , fill_value = None
@@ -8285,13 +8281,13 @@ def _construct_result(self, result, other=None) -> DataFrame:
82858281 -------
82868282 DataFrame
82878283 """
8288- if not getattr (self , "attrs" , None ) and getattr (other , "attrs" , None ):
8289- self .__finalize__ (other )
82908284 out = self ._constructor (result , copy = False ).__finalize__ (self )
82918285 # Pin columns instead of passing to constructor for compat with
82928286 # non-unique columns case
82938287 out .columns = self .columns
82948288 out .index = self .index
8289+ if not getattr (self , "attrs" , None ) and getattr (other , "attrs" , None ):
8290+ out = out .__finalize__ (other )
82958291 return out
82968292
82978293 def __divmod__ (self , other ) -> tuple [DataFrame , DataFrame ]:
0 commit comments