Skip to content

Commit f3ad4d5

Browse files
authored
REF: Make concat not stateful. (#59141)
* Make concat non stateful * Fix bug and error message * Update check * FIx typing
1 parent 039edee commit f3ad4d5

File tree

4 files changed

+311
-270
lines changed

4 files changed

+311
-270
lines changed

pandas/core/generic.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -6017,17 +6017,16 @@ def __finalize__(self, other, method: str | None = None, **kwargs) -> Self:
60176017
object.__setattr__(self, name, getattr(other, name, None))
60186018

60196019
if method == "concat":
6020+
objs = kwargs["objs"]
60206021
# propagate attrs only if all concat arguments have the same attrs
6021-
if all(bool(obj.attrs) for obj in other.objs):
6022+
if all(bool(obj.attrs) for obj in objs):
60226023
# all concatenate arguments have non-empty attrs
6023-
attrs = other.objs[0].attrs
6024-
have_same_attrs = all(obj.attrs == attrs for obj in other.objs[1:])
6024+
attrs = objs[0].attrs
6025+
have_same_attrs = all(obj.attrs == attrs for obj in objs[1:])
60256026
if have_same_attrs:
60266027
self.attrs = deepcopy(attrs)
60276028

6028-
allows_duplicate_labels = all(
6029-
x.flags.allows_duplicate_labels for x in other.objs
6030-
)
6029+
allows_duplicate_labels = all(x.flags.allows_duplicate_labels for x in objs)
60316030
self.flags.allows_duplicate_labels = allows_duplicate_labels
60326031

60336032
return self

0 commit comments

Comments
 (0)