Python UserWarning:此模式具有匹配组

Python UserWarning:此模式具有匹配组,python,pandas,Python,Pandas,我收到错误消息: import csv import os import pandas as pd os.chdir('C:\\Users\\khalha\\Desktop\\RealExcel') filename = 'sales.csv' Sales = pd.read_csv('sales.csv') iFlow = Sales.loc[Sales['Product'].str.contains('Vector HF/LF (Opt 2)', na=False), "18-Jun"]

我收到错误消息:

import csv
import os
import pandas as pd
os.chdir('C:\\Users\\khalha\\Desktop\\RealExcel')
filename = 'sales.csv'

Sales = pd.read_csv('sales.csv')
iFlow = Sales.loc[Sales['Product'].str.contains('Vector HF/LF (Opt 2)', 
na=False), "18-Jun"]
print(iFlow)

MaySales = pd.read_csv('maysales.csv')
iFlowmay = MaySales.loc[MaySales['Product'].str.contains('Vector HF/LF (Opt 
2)', na=False), "18-Jun"]
print(iFlowmay)
C:\Users\khalha\eclipse workspace\hariskk\hey\hello.py:8:UserWarning:此模式具有匹配组。要实际获取组,请使用str.extract。 iFlow=Sales.loc[Sales['Product'].str.contains('Vector HF/LF(Opt 2)),na=False),“6月18日”] 系列([],名称:6月18日,数据类型:object) C:\Users\khalha\eclipse workspace\hariskk\hey\hello.py:12:UserWarning:此模式具有匹配组。要实际获取组,请使用str.extract。 iFlowmay=MaySales.loc[MaySales['Product'].str.contains('Vector HF/LF(Opt 2)”,na=False),“6月18日”] 系列([],名称:6月18日,数据类型:object)
这段代码适用于第一个块,但当我添加Maysales部分时,它停止工作。

当您搜索包含括号的文本时,Python会感到困惑。我不能只运行您的代码,因为您正在导入数据帧,但我认为如果您只是这样做了:

C:\Users\khalha\eclipse-workspace\hariskk\hey\hello.py:8: UserWarning: This pattern has match groups. To actually get the groups, use str.extract. iFlow = Sales.loc[Sales['Product'].str.contains('Vector HF/LF (Opt 2)', na=False), "18-Jun"] Series([], Name: 18-Jun, dtype: object) C:\Users\khalha\eclipse-workspace\hariskk\hey\hello.py:12: UserWarning: This pattern has match groups. To actually get the groups, use str.extract. iFlowmay = MaySales.loc[MaySales['Product'].str.contains('Vector HF/LF (Opt 2)', na=False), "18-Jun"] Series([], Name: 18-Jun, dtype: object) 它会起作用的

iFlow = Sales.loc[Sales['Product'].str.contains('\Vector HF/LF (Opt 2', na=False), "18-Jun"]