當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python cudf.core.column.string.StringMethods.match用法及代碼示例

用法:

StringMethods.match(pat: str, case: bool = True, flags: int = 0) → SeriesOrIndex

確定每個字符串是否與正則表達式匹配。

參數

patstr 或編譯的正則表達式

字符序列或正則表達式。

flagsint,默認 0(無標誌)

傳遞給正則表達式引擎的標誌(例如 re.MULTILINE)

返回

布爾值的係列或索引。

注意

當前不支持參數casenaflags參數目前隻支持re.DOTALL和re.MULTILINE。

例子

>>> import cudf
>>> s = cudf.Series(["rapids", "ai", "cudf"])

檢查以 a 開頭的字符串。

>>> s.str.match('a')
0    False
1     True
2    False
dtype: bool

檢查以 ac 中的任何一個開頭的字符串。

>>> s.str.match('[ac]')
0    False
1     True
2     True
dtype: bool

相關用法


注:本文由純淨天空篩選整理自rapids.ai大神的英文原創作品 cudf.core.column.string.StringMethods.match。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。