按c列映射后,如果A列有值,则插入A列的值;如果不是,请插入 B 列。
data1 data2
a b c a c d
a1 b1 c1 1a c1 1d
b2 c2 2a c2 2d
a3 c3 3a c3 3d
4a c4 4d
我想要的结果
result
a b c
a1 b1 c1
2a b2 c2
a3 c3
我尝试了以下方法,但我并不满意。
->>> result = data1.merge(data2, on=['c'])
Prefixes _x and _y are created. combine_first is not applied.
->>> result = data1.combine_first(data2)
It is not mapped by column c.
我怎样才能得到好的结果?我请求你的帮助。谢谢你