From 4ff9ae4151f4dbb144d19353cbf6d9d251d9a3f2 Mon Sep 17 00:00:00 2001 From: Anuj Koli Date: Tue, 14 Dec 2021 15:35:19 -0500 Subject: [PATCH 1/2] Added an example for panda series str strip for nums and bool --- pandas/core/strings/accessor.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/pandas/core/strings/accessor.py b/pandas/core/strings/accessor.py index d5abd1606edec..48daa1a44c505 100644 --- a/pandas/core/strings/accessor.py +++ b/pandas/core/strings/accessor.py @@ -1894,7 +1894,7 @@ def encode(self, encoding, errors="strict"): See Also -------- - Series.str.strip : Remove leading and trailing characters in Series/Index. + Series.str.strip : Remove leading and trailing characters in Series/Index, it also replaces numeric and bool values with NaN. Series.str.lstrip : Remove leading characters in Series/Index. Series.str.rstrip : Remove trailing characters in Series/Index. @@ -1935,6 +1935,31 @@ def encode(self, encoding, errors="strict"): 2 Cat 3 NaN dtype: object + + s = pd.Series(['hello ', ' goodbye', 1.0, 0.0, 1, 0, True, False, np.nan]) + >>> s + 0 hello + 1 goodbye + 2 1.0 + 3 0.0 + 4 1 + 5 0 + 6 True + 7 False + 8 NaN + dtype: object + + >>> s.str.strip() + 0 hello + 1 goodbye + 2 NaN + 3 NaN + 4 NaN + 5 NaN + 6 NaN + 7 NaN + 8 NaN + dtype: object """ @Appender( From 2cd3cf2c8588e5449d4b7bfdff372547942dd2f2 Mon Sep 17 00:00:00 2001 From: Anuj Koli Date: Tue, 14 Dec 2021 15:42:34 -0500 Subject: [PATCH 2/2] Fixed issue with pre commit test --- pandas/core/strings/accessor.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandas/core/strings/accessor.py b/pandas/core/strings/accessor.py index 48daa1a44c505..24101c46ef0b2 100644 --- a/pandas/core/strings/accessor.py +++ b/pandas/core/strings/accessor.py @@ -1894,7 +1894,8 @@ def encode(self, encoding, errors="strict"): See Also -------- - Series.str.strip : Remove leading and trailing characters in Series/Index, it also replaces numeric and bool values with NaN. + Series.str.strip : Remove leading and trailing characters in Series/Index, + it also replaces numeric and bool values with NaN. Series.str.lstrip : Remove leading characters in Series/Index. Series.str.rstrip : Remove trailing characters in Series/Index. @@ -1938,7 +1939,7 @@ def encode(self, encoding, errors="strict"): s = pd.Series(['hello ', ' goodbye', 1.0, 0.0, 1, 0, True, False, np.nan]) >>> s - 0 hello + 0 hello 1 goodbye 2 1.0 3 0.0