Skip to content

Commit 61aba59

Browse files
committed
Provide new object for copy routines requiring info. on its destination.
1 parent 2547ff3 commit 61aba59

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pandas/core/generic.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6112,7 +6112,10 @@ def __finalize__(self, other, method: str | None = None, **kwargs) -> Self:
61126112
# impact if attrs are not used; i.e. attrs is an empty dict.
61136113
# One could make the deepcopy unconditionally, but a deepcopy
61146114
# of an empty dict is 50x more expensive than the empty check.
6115-
self.attrs = deepcopy(other.attrs)
6115+
# We provide the new dataset via the deepcopy memo to properly
6116+
# supply eventual attribute copy routines requiring information
6117+
# from its destination
6118+
self.attrs = deepcopy(other.attrs, memo={object:self})
61166119
self.flags.allows_duplicate_labels = (
61176120
self.flags.allows_duplicate_labels
61186121
and other.flags.allows_duplicate_labels

0 commit comments

Comments
 (0)