更新时间:2022-02-15 21:39:42
最终使用此解决方案:
containsFree = pd.read_excel('config_values.xlsx',
sheet_name='ContainsFree', header=None)
containsFree = '|'.join(containsFree[0])
df['ContainsFree'] = df.SearchQuery.str.contains(
containsFree, regex=True, flags=re.IGNORECASE)
我在每个Excel工作表中都使用了相同的代码.但是,对于第一个工作表,您无需传递工作表名称,即使它是正确的名称,也只需传递不带名称的文件即可:
I've used the same code per each excel sheet. However, for the first sheet you do not need to pass a sheet name, even if its the right one, just pass the file without the name:
containsbest = pd.read_excel('config_values.xlsx', header=None)
containsbest = '|'.join(containsbest[0])
df['Containsbest'] = df.SearchQuery.str.contains(
containsbest, regex=True, flags=re.IGNORECASE)