maxframe.dataframe.Series.str.endswith#

Series.str.endswith(pat: str | tuple[str, ...], na: Scalar | lib.NoDefault = <no_default>) Series | Index#

测试每个字符串元素的结尾是否与模式匹配。

等效于 str.endswith()

参数:
  • pat (str or tuple[str, ...]) -- 字符序列或字符串元组。不接受正则表达式。

  • na (scalar, optional) -- Object shown if element tested is not a string. The default depends on dtype of the array. For the "str" dtype, False is used. For object dtype, numpy.nan is used. For the nullable StringDtype, pandas.NA is used.

返回:

一个布尔值 Series,表示给定模式是否与每个字符串元素的结尾匹配。

返回类型:

Series or Index of bool

参见

str.endswith

Python 标准库字符串方法。

Series.str.startswith

与 endswith 相同,但测试字符串的开头。

Series.str.contains

测试字符串元素是否包含模式。

示例

>>> import maxframe.tensor as mt
>>> import maxframe.dataframe as md
>>> s = md.Series(["bat", "bear", "caT", mt.nan])
>>> s.execute()
0     bat
1    bear
2     caT
3     NaN
dtype: str
>>> s.str.endswith("t").execute()
0     True
1    False
2    False
3    False
dtype: bool
>>> s.str.endswith(("t", "T")).execute()
0     True
1    False
2     True
3    False
dtype: bool