Skip to content

Commit f3eaa55

Browse files
dcreekpjavadnoorb
authored andcommitted
DOC: update the pandas.Series.str.startswith docstring (pandas-dev#20458)
* DOC: update the pandas.Series.str.startswith docstring * DOC: update the pandas.Series.str.startswith docstring * DOC: update the pandas.Series.str.startswith docstring 2 * DOC: update the pandas.Series.str.startswith docstring 3 * DOC: update the pandas.Series.str.startswith docstring 4
1 parent cfad93f commit f3eaa55

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
@@ -328,19 +328,54 @@ def str_contains(arr, pat, case=True, flags=0, na=np.nan, regex=True):
328328

329329
def str_startswith(arr, pat, na=np.nan):
330330
"""
331-
Return boolean Series/``array`` indicating whether each string in the
332-
Series/Index starts with passed pattern. Equivalent to
333-
:meth:`str.startswith`.
331+
Test if the start of each string element matches a pattern.
332+
333+
Equivalent to :meth:`str.startswith`.
334334
335335
Parameters
336336
----------
337-
pat : string
338-
Character sequence
339-
na : bool, default NaN
337+
pat : str
338+
Character sequence. Regular expressions are not accepted.
339+
na : object, default NaN
340+
Object shown if element tested is not a string.
340341
341342
Returns
342343
-------
343-
startswith : Series/array of boolean values
344+
Series or Index of bool
345+
A Series of booleans indicating whether the given pattern matches
346+
the start of each string element.
347+
348+
See Also
349+
--------
350+
str.startswith : Python standard library string method.
351+
Series.str.endswith : Same as startswith, but tests the end of string.
352+
Series.str.contains : Tests if string element contains a pattern.
353+
354+
Examples
355+
--------
356+
>>> s = pd.Series(['bat', 'Bear', 'cat', np.nan])
357+
>>> s
358+
0 bat
359+
1 Bear
360+
2 cat
361+
3 NaN
362+
dtype: object
363+
364+
>>> s.str.startswith('b')
365+
0 True
366+
1 False
367+
2 False
368+
3 NaN
369+
dtype: object
370+
371+
Specifying `na` to be `False` instead of `NaN`.
372+
373+
>>> s.str.startswith('b', na=False)
374+
0 True
375+
1 False
376+
2 False
377+
3 False
378+
dtype: bool
344379
"""
345380
f = lambda x: x.startswith(pat)
346381
return _na_map(f, arr, na, dtype=bool)

0 commit comments

Comments
 (0)