Skip to content

Commit b1c54f4

Browse files
dcreekpTomAugspurger
authored andcommitted
DOC: update the pandas.Series.str.endswith docstring (#20491)
1 parent 9b4d0f1 commit b1c54f4

File tree

1 file changed

+42
-7
lines changed

1 file changed

+42
-7
lines changed

pandas/core/strings.py

+42-7
Original file line numberDiff line numberDiff line change
@@ -383,19 +383,54 @@ def str_startswith(arr, pat, na=np.nan):
383383

384384
def str_endswith(arr, pat, na=np.nan):
385385
"""
386-
Return boolean Series indicating whether each string in the
387-
Series/Index ends with passed pattern. Equivalent to
388-
:meth:`str.endswith`.
386+
Test if the end of each string element matches a pattern.
387+
388+
Equivalent to :meth:`str.endswith`.
389389
390390
Parameters
391391
----------
392-
pat : string
393-
Character sequence
394-
na : bool, default NaN
392+
pat : str
393+
Character sequence. Regular expressions are not accepted.
394+
na : object, default NaN
395+
Object shown if element tested is not a string.
395396
396397
Returns
397398
-------
398-
endswith : Series/array of boolean values
399+
Series or Index of bool
400+
A Series of booleans indicating whether the given pattern matches
401+
the end of each string element.
402+
403+
See Also
404+
--------
405+
str.endswith : Python standard library string method.
406+
Series.str.startswith : Same as endswith, but tests the start of string.
407+
Series.str.contains : Tests if string element contains a pattern.
408+
409+
Examples
410+
--------
411+
>>> s = pd.Series(['bat', 'bear', 'caT', np.nan])
412+
>>> s
413+
0 bat
414+
1 bear
415+
2 caT
416+
3 NaN
417+
dtype: object
418+
419+
>>> s.str.endswith('t')
420+
0 True
421+
1 False
422+
2 False
423+
3 NaN
424+
dtype: object
425+
426+
Specifying `na` to be `False` instead of `NaN`.
427+
428+
>>> s.str.endswith('t', na=False)
429+
0 True
430+
1 False
431+
2 False
432+
3 False
433+
dtype: bool
399434
"""
400435
f = lambda x: x.endswith(pat)
401436
return _na_map(f, arr, na, dtype=bool)

0 commit comments

Comments
 (0)