diff --git a/pandas/core/strings/accessor.py b/pandas/core/strings/accessor.py index b7ccc087ff1f1..f9dd17df6a47b 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 NaNs. Equivalent to :meth:`str.%(method)s`. Parameters @@ -1901,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() @@ -1914,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.') @@ -1921,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') @@ -1928,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') @@ -1935,6 +1944,8 @@ def encode(self, encoding, errors="strict"): 1 Bee 2 Cat 3 NaN + 4 NaN + 5 NaN dtype: object """