一、介绍

startswith 判断系列是否以指定字符开头

endswith 判断系列是否以指定字符结尾

使用语法:

Series.str.startswith(pat, na=nan)
Series.str.endswith(pat, na=nan)

参数:

pat -- 要搜索的字符串 不接受正则表达式
na -- 用于设置序列中的值为NULL时显示的内容

返回布尔序列,是否为真。

二、实操

s = pd.Series(['bat', 'Bear', 'cat', np.nan])
s.str.startswith('b')
s.str.startswith('b', na=False) # na=100

s.str.endswith('t', na=100)

参考链接:pandas.Series.str.startswith

参考链接:Python Pandas Series.str.startswith()用法及代码示例

相关文章:

  • 2022-12-23
  • 2021-07-04
  • 2022-12-23
  • 2021-10-04
  • 2021-12-29
  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-01
  • 2021-07-14
  • 2021-07-04
  • 2022-01-25
  • 2021-11-17
  • 2022-12-23
相关资源
相似解决方案