From 82dd4922a23269532c85983788eda99369f83c8c Mon Sep 17 00:00:00 2001 From: Lil Blick Date: Tue, 9 Jul 2024 11:00:32 -0700 Subject: [PATCH 1/2] add extra check for np arrays --- pandas/core/generic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 2a0495dff6681..2765b01927450 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -6040,7 +6040,7 @@ def __finalize__(self, other, method: str | None = None, **kwargs) -> Self: if all(bool(obj.attrs) for obj in objs): # all concatenate arguments have non-empty attrs attrs = objs[0].attrs - have_same_attrs = all(obj.attrs == attrs for obj in objs[1:]) + have_same_attrs = all((obj.attrs == attrs).all() if isinstance(obj.attrs, np.darray) else obj.attrs == attrs for obj in objs[1:]) if have_same_attrs: self.attrs = deepcopy(attrs) From b0e6e1750ca80b5a5b02bb7ddf8c52079525c046 Mon Sep 17 00:00:00 2001 From: Lil Blick Date: Tue, 9 Jul 2024 11:10:02 -0700 Subject: [PATCH 2/2] pre-commit checks reformat --- pandas/core/generic.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 2765b01927450..a7454424a1b04 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -6040,7 +6040,12 @@ def __finalize__(self, other, method: str | None = None, **kwargs) -> Self: if all(bool(obj.attrs) for obj in objs): # all concatenate arguments have non-empty attrs attrs = objs[0].attrs - have_same_attrs = all((obj.attrs == attrs).all() if isinstance(obj.attrs, np.darray) else obj.attrs == attrs for obj in objs[1:]) + have_same_attrs = all( + (obj.attrs == attrs).all() + if isinstance(obj.attrs, np.darray) + else obj.attrs == attrs + for obj in objs[1:] + ) if have_same_attrs: self.attrs = deepcopy(attrs)