maxframe.dataframe.Series.str.startswith#
- Series.str.startswith(pat: str | tuple[str, ...], na: Scalar | lib.NoDefault = <no_default>) Series | Index#
测试每个字符串元素的开头是否匹配某个模式。
等价于
str.startswith()。- 参数:
- 返回:
一个布尔值 Series,指示给定模式是否匹配每个字符串元素的开头。
- 返回类型:
参见
str.startswithPython 标准库字符串方法。
Series.str.endswith与 startswith 相同,但测试字符串的结尾。
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.startswith("b").execute() 0 True 1 False 2 False 3 False dtype: bool
>>> s.str.startswith(("b", "B")).execute() 0 True 1 True 2 False 3 False dtype: bool