Skip to content

Commit

Permalink
DOC: Minor addition to str.split (pandas-dev#46027)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ChrisAlbertsen authored Feb 22, 2022
1 parent 59ab400 commit 1c09a5d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pandas/core/strings/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -1901,40 +1902,50 @@ 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()
0 1. Ant.
1 2. Bee!
2 3. Cat?
3 NaN
4 NaN
5 NaN
dtype: object
>>> s.str.lstrip('123.')
0 Ant.
1 Bee!\n
2 Cat?\t
3 NaN
4 NaN
5 NaN
dtype: object
>>> s.str.rstrip('.!? \n\t')
0 1. Ant
1 2. Bee
2 3. Cat
3 NaN
4 NaN
5 NaN
dtype: object
>>> s.str.strip('123.!? \n\t')
0 Ant
1 Bee
2 Cat
3 NaN
4 NaN
5 NaN
dtype: object
"""

Expand Down

0 comments on commit 1c09a5d

Please sign in to comment.