国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術文章
文章詳情頁

Python:UserWarning:此模式具有匹配組。要實際獲得組,請使用str.extract

瀏覽:4日期:2022-08-07 13:30:45
如何解決Python:UserWarning:此模式具有匹配組。要實際獲得組,請使用str.extract?

中的至少一個正則表達式模式urls必須使用捕獲組。 str.contains僅針對其中的每一行返回True或Falsedf[’event_time’]-不使用捕獲組。因此,UserWarning警告您正則表達式使用捕獲組,但未使用匹配項。

如果要刪除,則UserWarning可以從正則表達式模式中找到并刪除捕獲組。它們沒有顯示在您發布的正則表達式模式中,但是它們必須在您的實際文件中。在字符類之外查找括號。

或者,您可以通過以下方式禁止此特定的UserWarning

import warningswarnings.filterwarnings('ignore', ’This pattern has match groups’)

在致電之前str.contains。

這是一個簡單的示例,演示了問題(和解決方案):

# import warnings# warnings.filterwarnings('ignore', ’This pattern has match groups’) # uncomment to suppress the UserWarningimport pandas as pddf = pd.DataFrame({ ’event_time’: [’gouda’, ’stilton’, ’gruyere’]})urls = pd.DataFrame({’url’: [’g(.*)’]}) # With a capturing group, there is a UserWarning# urls = pd.DataFrame({’url’: [’g.*’]}) # Without a capturing group, there is no UserWarning. Uncommenting this line avoids the UserWarning.substr = urls.url.values.tolist()df[df[’event_time’].str.contains(’|’.join(substr), regex=True)]

版畫

script.py:10: UserWarning: This pattern has match groups. To actually get the groups, use str.extract. df[df[’event_time’].str.contains(’|’.join(substr), regex=True)]

從正則表達式模式中刪除捕獲組:

urls = pd.DataFrame({’url’: [’g.*’]})

避免了UserWarning。

解決方法

我有一個數據框,我嘗試獲取字符串,其中的列上包含一些字符串Df像

member_id,event_path,event_time,event_duration30595,'2016-03-30 12:27:33',yandex.ru/,130595,'2016-03-30 12:31:42',030595,'2016-03-30 12:31:43',yandex.ru/search/?lr=10738&msid=22901.25826.1459330364.89548&text=%D1%84%D0%B8%D0%BB%D1%8C%D0%BC%D1%8B+%D0%BE%D0%BD%D0%BB%D0%B0%D0%B9%D0%BD&suggest_reqid=168542624144922467267026838391360&csg=3381%2C3938%2C2%2C3%2C1%2C0%2C0,'2016-03-30 12:31:44','2016-03-30 12:31:45','2016-03-30 12:31:46','2016-03-30 12:31:49',kinogo.co/,'2016-03-30 12:32:11',kinogo.co/melodramy/,0

和另一個帶有網址的df

url003.ru/[a-zA-Z0-9-_%$#?.:+=|()]+/mobilnyj_telefon_bq_phoenix003.ru/[a-zA-Z0-9-_%$#?.:+=|()]+/mobilnyj_telefon_fly_003.ru/sonyxperia003.ru/[a-zA-Z0-9-_%$#?.:+=|()]+/mobilnye_telefony_smartfony003.ru/[a-zA-Z0-9-_%$#?.:+=|()]+/mobilnye_telefony_smartfony/brands5D5Bbr_231click.ru/sonyxperia1click.ru/[a-zA-Z0-9-_%$#?.:+=|()]+/chasy-motorola

我用

urls = pd.read_csv(’relevant_url1.csv’,error_bad_lines=False)substr = urls.url.values.tolist()data = pd.read_csv(’data_nts2.csv’,error_bad_lines=False,chunksize=50000)result = pd.DataFrame()for i,df in enumerate(data): res = df[df[’event_time’].str.contains(’|’.join(substr),regex=True)]

但它還給我

UserWarning: This pattern has match groups. To actually get the groups,use str.extract.

我該如何解決?

標簽: Python 編程
主站蜘蛛池模板: 天堂一区二区三区精品 | 国产欧美日韩精品一区二区三区 | 国产萌白酱在线一区二区 | 在线a亚洲视频播放在线观看 | 本道久久综合88全国最大色 | 国产伦精品一区二区三区无广告 | 男人女人做刺激视频免费 | 国内精品久久久久不卡 | 成人黄网大全在线观看 | 欧美亚洲日本视频 | 亚洲国产成人久久一区久久 | avtom影院入口永久在线观看 | 欧美一级特黄视频 | 911精品国产91久久久久 | 香蕉久久久久 | 亚洲一区二区三区福利在线 | 亚洲在线偷拍自拍 | 欧美操操操 | 亚洲产国偷v产偷v自拍涩爱 | 在线观看黄网视频免费播放 | 免费萌白酱国产一区二区三区 | 中国胖女人一级毛片aaaaa | 亚洲第一区香蕉_国产a | 97国产精品视频观看一 | 久久一日本道色综合久久 | 日韩精品久久久毛片一区二区 | 成人男女网18免费91 | 欧美性久久久久 | 夜夜骚视频| 欧美日韩不卡在线 | 日本 片 成人 在线 日本68xxxxxxxxx老师 | 99久久精品国产一区二区 | 日本老熟妇激情毛片 | 精品国产无限资源免费观看 | 爽爽爽爽爽爽a成人免费视频 | 综合精品视频 | 国产精品久久久久久麻豆一区 | 欧美亚洲国产精品 | 日韩99在线 | 亚洲制服欧美自拍另类 | 一级特黄aaa大片在 一级特黄aaa大片在线观看 |