From 6c677bc2cdafb5b7a402dc720cda09bb78a9ee6f Mon Sep 17 00:00:00 2001 From: bang128 <71242233+bang128@users.noreply.github.com> Date: Thu, 1 Dec 2022 23:10:51 -0800 Subject: [PATCH 1/6] Update accessor.py --- pandas/core/strings/accessor.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pandas/core/strings/accessor.py b/pandas/core/strings/accessor.py index 71a50c69bfee1..44ba746ef781b 100644 --- a/pandas/core/strings/accessor.py +++ b/pandas/core/strings/accessor.py @@ -569,9 +569,7 @@ def cat( # concatenate Series/Index with itself if no "others" if others is None: - # error: Incompatible types in assignment (expression has type - # "ndarray", variable has type "Series") - data = ensure_object(data) # type: ignore[assignment] + data = Series(ensure_object(data)) na_mask = isna(data) if na_rep is None and na_mask.any(): return sep.join(data[~na_mask]) From 7c1748a431b9d354def0d23a66a359b17abb7e0e Mon Sep 17 00:00:00 2001 From: bang128 <71242233+bang128@users.noreply.github.com> Date: Tue, 6 Dec 2022 22:24:10 -0800 Subject: [PATCH 2/6] Update accessor.py --- pandas/core/strings/accessor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/strings/accessor.py b/pandas/core/strings/accessor.py index 44ba746ef781b..092be069be243 100644 --- a/pandas/core/strings/accessor.py +++ b/pandas/core/strings/accessor.py @@ -569,7 +569,7 @@ def cat( # concatenate Series/Index with itself if no "others" if others is None: - data = Series(ensure_object(data)) + data = ensure_object(data) na_mask = isna(data) if na_rep is None and na_mask.any(): return sep.join(data[~na_mask]) From 12b7360c68c004b91ec3d3b963616c16c91bc887 Mon Sep 17 00:00:00 2001 From: bang128 <71242233+bang128@users.noreply.github.com> Date: Tue, 6 Dec 2022 23:30:21 -0800 Subject: [PATCH 3/6] Update accessor.py --- pandas/core/strings/accessor.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/core/strings/accessor.py b/pandas/core/strings/accessor.py index 092be069be243..2da84ec32715e 100644 --- a/pandas/core/strings/accessor.py +++ b/pandas/core/strings/accessor.py @@ -570,6 +570,7 @@ def cat( # concatenate Series/Index with itself if no "others" if others is None: data = ensure_object(data) + data = Series(data, index=self._orig, dtype=self._orig.dtype) na_mask = isna(data) if na_rep is None and na_mask.any(): return sep.join(data[~na_mask]) From d929fe59315da40fe3ebe81b1d477b6217a67e6f Mon Sep 17 00:00:00 2001 From: bang128 <71242233+bang128@users.noreply.github.com> Date: Tue, 6 Dec 2022 23:38:50 -0800 Subject: [PATCH 4/6] Update accessor.py --- pandas/core/strings/accessor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/strings/accessor.py b/pandas/core/strings/accessor.py index 2da84ec32715e..26504f53df35d 100644 --- a/pandas/core/strings/accessor.py +++ b/pandas/core/strings/accessor.py @@ -569,8 +569,8 @@ def cat( # concatenate Series/Index with itself if no "others" if others is None: - data = ensure_object(data) - data = Series(data, index=self._orig, dtype=self._orig.dtype) + temp = ensure_object(data) + data = Series(temp) na_mask = isna(data) if na_rep is None and na_mask.any(): return sep.join(data[~na_mask]) From 46556b2194c186db89b909e5e59c95c54184e92f Mon Sep 17 00:00:00 2001 From: bang128 <71242233+bang128@users.noreply.github.com> Date: Tue, 6 Dec 2022 23:50:41 -0800 Subject: [PATCH 5/6] Update accessor.py --- pandas/core/strings/accessor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/strings/accessor.py b/pandas/core/strings/accessor.py index 26504f53df35d..fa228fba86ee9 100644 --- a/pandas/core/strings/accessor.py +++ b/pandas/core/strings/accessor.py @@ -562,6 +562,8 @@ def cat( if sep is None: sep = "" + data: Series + if isinstance(self._orig, ABCIndex): data = Series(self._orig, index=self._orig, dtype=self._orig.dtype) else: # Series @@ -569,8 +571,6 @@ def cat( # concatenate Series/Index with itself if no "others" if others is None: - temp = ensure_object(data) - data = Series(temp) na_mask = isna(data) if na_rep is None and na_mask.any(): return sep.join(data[~na_mask]) From 01a287e509d107b8781ce39383d110f8b6a52d9e Mon Sep 17 00:00:00 2001 From: bang128 <71242233+bang128@users.noreply.github.com> Date: Wed, 7 Dec 2022 14:34:35 -0800 Subject: [PATCH 6/6] Update accessor.py --- pandas/core/strings/accessor.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/core/strings/accessor.py b/pandas/core/strings/accessor.py index fa228fba86ee9..f8dad3b252223 100644 --- a/pandas/core/strings/accessor.py +++ b/pandas/core/strings/accessor.py @@ -562,7 +562,7 @@ def cat( if sep is None: sep = "" - data: Series + data: Series | np.ndarray if isinstance(self._orig, ABCIndex): data = Series(self._orig, index=self._orig, dtype=self._orig.dtype) @@ -571,6 +571,7 @@ def cat( # concatenate Series/Index with itself if no "others" if others is None: + data = ensure_object(data) na_mask = isna(data) if na_rep is None and na_mask.any(): return sep.join(data[~na_mask])