我想比较是否'df2'数据框的列'名称'中的值存在于'df1'列'名称' 。我想用自定义字符串'Other'来更新df1 ['Names']中的不匹配值。我不想编辑和其他列中的任何值。熊猫:根据其他数据框中的列替换一个数据帧的特定列中的值
有人可以帮我得到预期的结果吗?
df1
Names Method
0 Ram GET
1 Sham POST
2 Ganesh READ
3 Ramesh GET
4 Deepak POST
df2
Names
0 Sham
1 Ram
DF1的
预期结果:
df1
Names Method
0 Ram GET
1 Sham POST
2 Other READ
3 Other GET
4 Other POST
会这个工作:'df1.loc [〜df1 ['Names']。isin(df2 ['Names']),'Names'] ='Other''? – stephan
It works ..你真棒! –
@stephan,你是否介意将你的评论变成答案 - 所以问题不会得到解答? – MaxU