Skip to content

Commit 1c09a5d

Browse files
DOC: Minor addition to str.split (#46027)
* DOC: Minor addition to str.split * Make Series uppercase and NaN plural * example suggestion for method behaviour * allign Series values in hopes of passing tests * fixed lowercase Nan typing error
1 parent 59ab400 commit 1c09a5d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

pandas/core/strings/accessor.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1880,6 +1880,7 @@ def encode(self, encoding, errors="strict"):
18801880
18811881
Strip whitespaces (including newlines) or a set of specified characters
18821882
from each string in the Series/Index from %(side)s.
1883+
Replaces any non-strings in Series with NaNs.
18831884
Equivalent to :meth:`str.%(method)s`.
18841885
18851886
Parameters
@@ -1901,40 +1902,50 @@ def encode(self, encoding, errors="strict"):
19011902
19021903
Examples
19031904
--------
1904-
>>> s = pd.Series(['1. Ant. ', '2. Bee!\n', '3. Cat?\t', np.nan])
1905+
>>> s = pd.Series(['1. Ant. ', '2. Bee!\n', '3. Cat?\t', np.nan, 10, True])
19051906
>>> s
19061907
0 1. Ant.
19071908
1 2. Bee!\n
19081909
2 3. Cat?\t
19091910
3 NaN
1911+
4 10
1912+
5 True
19101913
dtype: object
19111914
19121915
>>> s.str.strip()
19131916
0 1. Ant.
19141917
1 2. Bee!
19151918
2 3. Cat?
19161919
3 NaN
1920+
4 NaN
1921+
5 NaN
19171922
dtype: object
19181923
19191924
>>> s.str.lstrip('123.')
19201925
0 Ant.
19211926
1 Bee!\n
19221927
2 Cat?\t
19231928
3 NaN
1929+
4 NaN
1930+
5 NaN
19241931
dtype: object
19251932
19261933
>>> s.str.rstrip('.!? \n\t')
19271934
0 1. Ant
19281935
1 2. Bee
19291936
2 3. Cat
19301937
3 NaN
1938+
4 NaN
1939+
5 NaN
19311940
dtype: object
19321941
19331942
>>> s.str.strip('123.!? \n\t')
19341943
0 Ant
19351944
1 Bee
19361945
2 Cat
19371946
3 NaN
1947+
4 NaN
1948+
5 NaN
19381949
dtype: object
19391950
"""
19401951

0 commit comments

Comments
 (0)