StringMethods.startswith(pat: str | Sequence) SeriesOrIndex#

Test if the start of each string element matches a pattern.

Equivalent to str.startswith().

patstr or list-like

If str is an str, evaluates whether each string of series starts with pat. If pat is a list-like, evaluates whether self[i] starts with pat[i]. Regular expressions are not accepted.

Series or Index of bool

A Series of booleans indicating whether the given pattern matches the start of each string element.

See also


Same as startswith, but tests the end of string.


Tests if string element contains a pattern.


>>> import cudf
>>> s = cudf.Series(['bat', 'Bear', 'cat', None])
>>> s
0     bat
1    Bear
2     cat
3    <NA>
dtype: object
>>> s.str.startswith('b')
0     True
1    False
2    False
3     <NA>
dtype: bool