0 1 20 sun is rising | UNKNowN | 14654651 micheal has arrived | UNKNowN | 3246542 goal has been scored | UNKNowN | 547854
和其他有价值的XYZ
0 1 0 sun | password11 goal | password22 micheal | password3
如何将XYZ与(太阳,目标和米歇尔)ABC进行映射,以便1用密码替换ABC中的UNKNowN 1
输出我需要
0 1 20 sun is rising | password1 | 14654651 micheal has arrived | password3 | 3246542 goal has been scored| password2 | 547854解决方法
d = dict(zip(XYZ[0],XYZ[1]))#{'sun': 'password1','goal': 'password2','micheal': 'password3'}pat = (r'({})'.format('|'.join(d.keys())))ABC[1]=ABC[0].str.extract(pat,expand=False).map(d)print(ABC) 0 1 20 sun is rising password1 14654651 micheal has arrived password3 3246542 goal has been scored password2 547854总结
以上是内存溢出为你收集整理的如何匹配和合并两个具有完全不同的值的数据帧,除了一个单词?全部内容,希望文章能够帮你解决如何匹配和合并两个具有完全不同的值的数据帧,除了一个单词?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)