Pandas 熊猫:这是什么样的加入?还是加入?
我试图用B更新Pandas 熊猫:这是什么样的加入?还是加入?,pandas,Pandas,我试图用B更新dfA以生成C A= B= C= 也许不需要加入?Dagnabit!也打败我吧。我有完全相同的解决办法。@ScottBoston有点冗长:)达纳比特!也打败我吧。我有完全相同的解决方案。@ScottBoston有点冗长:) 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 m
df
A以生成C
A=
B=
C=
也许不需要加入?Dagnabit!也打败我吧。我有完全相同的解决办法。@ScottBoston有点冗长:)达纳比特!也打败我吧。我有完全相同的解决方案。@ScottBoston有点冗长:)
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
Name city
adam e
mike f
Name city
bob a
adam e
mike f
fred d
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