pandas.Series.str.endswith

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

Equivalent to str.endswith().

param pat
str

Character sequence. Regular expressions are not accepted.

param na
object, default NaN

Object shown if element tested is not a string.

return

Series or Index of bool A Series of booleans indicating whether the given pattern matches the end of each string element.

Limitations

Series elements are expected to be Unicode strings. Elements cannot be NaNs. Parameter na is supported only with default value None.

Examples

Test if the end of each string element matches a string
import pandas as pd
from numba import njit


@njit
def series_str_endswith():
    series = pd.Series(['foo', 'bar', 'foobar'])  # Series of 'foo', 'bar', 'foobar'
    out_series = series.str.endswith('bar')

    return out_series  # Expect series of False, True, True


print(series_str_endswith())
$ python ./series/str/series_str_endswith.py
0    False
1     True
2     True
dtype: bool

See also

str.endswith

Python standard library string method.

Series.str.startswith

Same as endswith, but tests the start of string.

Series.str.contains

Tests if string element contains a pattern.

Todo

  • Add support of matching the end of each string by a pattern

  • Add support of parameter na