我正在尝试用B更新df
A以生成C.
A =
Name city
bob a
adam b
mike c
fred d
B =
Name city
adam e
mike f
C =
Name city
bob a
adam e
mike f
fred d
也许没有必要加入?
答案 0 :(得分:2)
B.set_index('Name').combine_first(A.set_index('Name')).reset_index()
Out:
Name city
0 adam e
1 bob a
2 fred d
3 mike f