From a457303da8839d0a64bb7b54fc3139b25f686693 Mon Sep 17 00:00:00 2001 From: ChrisAlbertsen Date: Wed, 16 Feb 2022 21:33:04 +0100 Subject: [PATCH 1/5] DOC: Minor addition to str.split --- 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 b7ccc087ff1f1..1ecdf06851258 100644 --- a/pandas/core/strings/accessor.py +++ b/pandas/core/strings/accessor.py @@ -1880,6 +1880,7 @@ def encode(self, encoding, errors="strict"): Strip whitespaces (including newlines) or a set of specified characters from each string in the Series/Index from %(side)s. + Replaces any non-strings in series with NaN. Equivalent to :meth:`str.%(method)s`. Parameters From 1a657489f7f42ee1089ee5f59e32c8a2d34ef574 Mon Sep 17 00:00:00 2001 From: ChrisAlbertsen Date: Wed, 16 Feb 2022 21:40:02 +0100 Subject: [PATCH 2/5] Make Series uppercase and NaN plural --- 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 1ecdf06851258..67494ee89bdc3 100644 --- a/pandas/core/strings/accessor.py +++ b/pandas/core/strings/accessor.py @@ -1880,7 +1880,7 @@ def encode(self, encoding, errors="strict"): Strip whitespaces (including newlines) or a set of specified characters from each string in the Series/Index from %(side)s. - Replaces any non-strings in series with NaN. + Replaces any non-strings in Series with NaNs. Equivalent to :meth:`str.%(method)s`. Parameters From 892988e0bdb5fc72ffd4be0ca928428771b9b0cb Mon Sep 17 00:00:00 2001 From: ChrisAlbertsen Date: Wed, 16 Feb 2022 22:09:10 +0100 Subject: [PATCH 3/5] example suggestion for method behaviour --- pandas/core/strings/accessor.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pandas/core/strings/accessor.py b/pandas/core/strings/accessor.py index 67494ee89bdc3..fed594eec01a5 100644 --- a/pandas/core/strings/accessor.py +++ b/pandas/core/strings/accessor.py @@ -1902,12 +1902,14 @@ def encode(self, encoding, errors="strict"): Examples -------- - >>> s = pd.Series(['1. Ant. ', '2. Bee!\n', '3. Cat?\t', np.nan]) + >>> s = pd.Series(['1. Ant. ', '2. Bee!\n', '3. Cat?\t', np.nan, 10, True]) >>> s 0 1. Ant. 1 2. Bee!\n 2 3. Cat?\t 3 NaN + 4 10 + 5 True dtype: object >>> s.str.strip() @@ -1915,6 +1917,8 @@ def encode(self, encoding, errors="strict"): 1 2. Bee! 2 3. Cat? 3 NaN + 4 Nan + 5 NaN dtype: object >>> s.str.lstrip('123.') @@ -1922,6 +1926,8 @@ def encode(self, encoding, errors="strict"): 1 Bee!\n 2 Cat?\t 3 NaN + 4 Nan + 5 NaN dtype: object >>> s.str.rstrip('.!? \n\t') @@ -1929,6 +1935,8 @@ def encode(self, encoding, errors="strict"): 1 2. Bee 2 3. Cat 3 NaN + 4 Nan + 5 NaN dtype: object >>> s.str.strip('123.!? \n\t') @@ -1936,6 +1944,8 @@ def encode(self, encoding, errors="strict"): 1 Bee 2 Cat 3 NaN + 4 Nan + 5 NaN dtype: object """ From 587c32ac7200e1ea100c79aef0361c3b8e2a782d Mon Sep 17 00:00:00 2001 From: ChrisAlbertsen Date: Wed, 16 Feb 2022 22:40:43 +0100 Subject: [PATCH 4/5] allign Series values in hopes of passing tests --- 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 fed594eec01a5..742302b9b578e 100644 --- a/pandas/core/strings/accessor.py +++ b/pandas/core/strings/accessor.py @@ -1908,8 +1908,8 @@ def encode(self, encoding, errors="strict"): 1 2. Bee!\n 2 3. Cat?\t 3 NaN - 4 10 - 5 True + 4 10 + 5 True dtype: object >>> s.str.strip() From 3afca2501fc39b75822c33435061cd19572e6631 Mon Sep 17 00:00:00 2001 From: ChrisAlbertsen Date: Thu, 17 Feb 2022 17:10:17 +0100 Subject: [PATCH 5/5] fixed lowercase Nan typing error --- pandas/core/strings/accessor.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/core/strings/accessor.py b/pandas/core/strings/accessor.py index 742302b9b578e..f9dd17df6a47b 100644 --- a/pandas/core/strings/accessor.py +++ b/pandas/core/strings/accessor.py @@ -1917,7 +1917,7 @@ def encode(self, encoding, errors="strict"): 1 2. Bee! 2 3. Cat? 3 NaN - 4 Nan + 4 NaN 5 NaN dtype: object @@ -1926,7 +1926,7 @@ def encode(self, encoding, errors="strict"): 1 Bee!\n 2 Cat?\t 3 NaN - 4 Nan + 4 NaN 5 NaN dtype: object @@ -1935,7 +1935,7 @@ def encode(self, encoding, errors="strict"): 1 2. Bee 2 3. Cat 3 NaN - 4 Nan + 4 NaN 5 NaN dtype: object @@ -1944,7 +1944,7 @@ def encode(self, encoding, errors="strict"): 1 Bee 2 Cat 3 NaN - 4 Nan + 4 NaN 5 NaN dtype: object """