熊猫值错误:模式不包含捕获组

使用正则表达式时,我得到:


import re

string = r'http://www.example.com/abc.html'

result = re.search('^.*com', string).group()

在熊猫中,我写道:


df = pd.DataFrame(columns = ['index', 'url'])

df.loc[len(df), :] = [1, 'http://www.example.com/abc.html']

df.loc[len(df), :] = [2, 'http://www.hello.com/def.html']

df.str.extract('^.*com')


ValueError: pattern contains no capture groups

如何解决问题?


一只名叫tom的猫
浏览 356回答 3
3回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python