我有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
现在我需要用df2中的新值检查df1中的m值,如果它匹配,我需要将新值的细节合并到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
下面是一个基于NumPy的方法,它通过
np.isin
测试2d数组中的每个值与1d数组。但实际上,这应该被视为最后的手段:串联的列表效率低下,而且对于大型数据集,您将面临性能问题。你知道吗注意
argmax
将只检查第一个匹配,如果列表中存在多个匹配。你知道吗相关问题 更多 >
编程相关推荐