文本处理中是否有re.fullmatch等价物?pandas到目前为止,我只遇到了re.match等价的pandas.Series.str.match.
如果特定熊猫单元格中的整个字符串与正则表达式模式匹配,我基本上想返回成功匹配。
这是我到目前为止所拥有的pandas.Series.str.match:
s = pd.Series(['AB', 'ABC', 'PQ', 'PQR'])
regex = 'AB|PQ'
s.str.match(regex)
但是,当我只希望第一个元素和第三个元素匹配时,这将返回sas的所有元素。True'AB''PQ'
上述代码的输出:
0 True
1 True
2 True
3 True
dtype: bool
期望的输出:
0 True
1 False
2 True
3 False
dtype: bool