我有一个excel-1(原始数据)和excel-2(参考文档)
在excel-1中,"Comments“应与excel-2 \f25 "Comments”-2\f6中的"comments“-2\f6进行匹配。-1\f25 excel-1 \f25 "comments”-1\f6列中的字符串包含-2\f25 excel-2 \f25“comments”-2\f6列中的任意子字符串,excel-2 \f6中的-2\f25 matched -2\f6和-2\f25 the -2\f6应在-2\f25 excel-1 \f6中的每一行中填写。-2\f25 column.If -2\f6。
Excel-1 {'Item':{0:'rr-1',1:'ss-2'},' order ':{0: 1,1: 2},'Comments':{0:‘好;库存无序,#1237-MF,关闭库存',1:’没有变化,不好,下周交货,09/12/2018-MF*‘}}
Excel-2 {‘评论’:{0:‘好',1:’缺货',2:‘库存关闭’,3:‘无变化’,4:‘不良库存’,5:‘下周发货'},’主要原因‘:{0:’质量‘,1:’仓库‘,2:’物流‘,3:’反馈‘,4:’仓库‘,5:’物流'},‘次要原因’:{0:‘制造’,1:‘库存’,2:‘仓库’,3:‘反馈’,4:‘库存’,5:‘仓库’}}
请帮助构建逻辑。
当有一个匹配项时,我使用pd.dataframe.str.concludes/isin函数得到了答案,但是如何编写逻辑来搜索多个匹配项,并以特定的结构格式编写。

for value in df['Comments']:
string = re.sub(r'[?|$|.|!|,|;]',r'',value)
for index,value in df1.iterrows():
substring = df1.Comment[index]
if substring in string:
df['Primary Reason']= df1['Primary Reason'][index]
df['Secondary Reason']=df1['Secondary Reason'][index]发布于 2018-09-21 04:14:30
对于df‘’Comments‘中的值
string = re.sub(r'[?|$|.|!|,|;]',r'',value)
for index,value in df1.iterrows():
substring = df1.Comment[index]
if substring in string:
df['Primary Reason']= df1['Primary Reason'][index]
df['Secondary Reason']=df1['Secondary Reason'][index]以上代码的分析:
问题出现在以下代码中:
df['Primary Reason']= df1['Primary Reason'][index]
df['Secondary Reason']=df1['Secondary Reason'][index]res1,res2 ....etc
https://stackoverflow.com/questions/52426807
复制相似问题