【发布时间】:2019-03-10 04:15:21
【问题描述】:
我有 2 个 csv 文件 df1
x y z m
a b c [apple,iphone,watch,newdevice]
e w q NaN
w r t [pixel,google]
s t q [india,computer]
df2
new code file
apple appl ofo
lg weew ofe
htc rrr ofr
google ggle ofg
现在我需要检查 df1 中的 m 值与 df2 中的新值是否匹配,我需要将新值的详细信息与 df1 结合起来,否则我们需要填充空值 我需要使用python请帮助我
样本输出
x y z m code file
a b c [apple,iphone,watch,newdevice] aapl ofo
e w q NaN null null
w r t [pixel,google,] ggle ofg
s t q [india,computer] null null
【问题讨论】:
-
m是一列列表吗? -
是的,它是一列列表
-
合并列是否总是列表中的第一项?如果是这种情况,它会简化很多
-
@SvenH。不,可能不是这样,它可能会改变:- [iphone , apple] 或 [iphone , watch , apple] 或 [pixel,google,pixelbuds]
-
列表是否可以像
['apple', 'google']一样映射到df2中的多行?
标签: python string pandas merge comparison