本文簡要介紹
pyspark.pandas.Series.str.count
的用法。用法:
str.count(pat: str, flags: int = 0) → ps.Series
計算係列中每個字符串中模式的出現次數。
此函數用於計算特定正則表達式模式在係列的每個字符串元素中重複的次數。
- pat:str
有效的正則表達式。
- flags:int,默認 0(無標誌)
re 模塊的標誌。
- int係列
包含模式匹配整數計數的係列。
參數:
返回:
例子:
>>> s = ps.Series(['A', 'B', 'Aaba', 'Baca', np.NaN, 'CABA', 'cat']) >>> s.str.count('a') 0 0.0 1 0.0 2 2.0 3 2.0 4 NaN 5 0.0 6 1.0 dtype: float64
轉義“$”以找到文字美元符號。
>>> s = ps.Series(['$', 'B', 'Aab$', '$$ca', 'C$B$', 'cat']) >>> s.str.count('\$') 0 1 1 0 2 1 3 2 4 2 5 0 dtype: int64
相關用法
- Python pyspark Series.str.contains用法及代碼示例
- Python pyspark Series.str.capitalize用法及代碼示例
- Python pyspark Series.str.center用法及代碼示例
- Python pyspark Series.str.join用法及代碼示例
- Python pyspark Series.str.startswith用法及代碼示例
- Python pyspark Series.str.slice_replace用法及代碼示例
- Python pyspark Series.str.rjust用法及代碼示例
- Python pyspark Series.str.lstrip用法及代碼示例
- Python pyspark Series.str.len用法及代碼示例
- Python pyspark Series.str.slice用法及代碼示例
- Python pyspark Series.str.isnumeric用法及代碼示例
- Python pyspark Series.str.endswith用法及代碼示例
- Python pyspark Series.str.swapcase用法及代碼示例
- Python pyspark Series.str.isdecimal用法及代碼示例
- Python pyspark Series.str.rstrip用法及代碼示例
- Python pyspark Series.str.istitle用法及代碼示例
- Python pyspark Series.str.match用法及代碼示例
- Python pyspark Series.str.rindex用法及代碼示例
- Python pyspark Series.str.rsplit用法及代碼示例
- Python pyspark Series.str.strip用法及代碼示例
- Python pyspark Series.str.ljust用法及代碼示例
- Python pyspark Series.str.title用法及代碼示例
- Python pyspark Series.str.upper用法及代碼示例
- Python pyspark Series.str.isupper用法及代碼示例
- Python pyspark Series.str.pad用法及代碼示例
注:本文由純淨天空篩選整理自spark.apache.org大神的英文原創作品 pyspark.pandas.Series.str.count。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。