@@ -5972,27 +5972,32 @@ def pipe(
5972
5972
# Attribute access
5973
5973
5974
5974
@final
5975
- def __finalize__ (self , other , method : str | None = None , ** kwargs ) -> Self :
5976
- """
5977
- Propagate metadata from other to self.
5978
5975
5979
- Parameters
5980
- ----------
5981
- other : the object from which to get the attributes that we are going
5982
- to propagate
5983
- method : str, optional
5984
- A passed method name providing context on where ``__finalize__``
5985
- was called.
5976
+ @final
5977
+ def __finalize__ (self , other , method : str | None = None , ** kwargs ) -> Self :
5978
+ """
5979
+ Propagate metadata from other to self.
5980
+
5981
+ Parameters
5982
+ ----------
5983
+ other : the object from which to get the attributes that we are going
5984
+ to propagate
5985
+ method : str, optional
5986
+ A passed method name providing context on where ``__finalize__``
5987
+ was called.
5986
5988
5987
- .. warning::
5989
+ .. warning::
5990
+
5991
+ The value passed as `method` are not currently considered
5992
+ stable across pandas releases.
5993
+ """
5994
+ if isinstance (other , NDFrame ):
5995
+ if other .attrs :
5996
+ self .attrs .update (other .attrs )
5997
+ if hasattr (other , 'flags' ):
5998
+ self .flags = other .flags
5999
+ return self
5988
6000
5989
- The value passed as `method` are not currently considered
5990
- stable across pandas releases.
5991
- """
5992
- if isinstance (other , NDFrame ):
5993
- if other .attrs :
5994
- # We want attrs propagation to have minimal performance
5995
- # impact if attrs are not used; i.e. attrs is an empty dict.
5996
6001
# One could make the deepcopy unconditionally, but a deepcopy
5997
6002
# of an empty dict is 50x more expensive than the empty check.
5998
6003
self .attrs = deepcopy (other .attrs )
0 commit comments