Reputation: 3754
I have DataFrame like this
A B C D
010 100 NaN 300
020 NaN 200 400
020 100 NaN NaN
030 NaN NaN 19
030 1 NaN NaN
040 NaN 2 1
How can I merge all rows that have duplicate (same value) in Column A
so that other values fill the empty places?
End result
A B C D
010 100 NaN 300
020 100 200 400
030 1 NaN 19
040 NaN 2 1
Upvotes: 0
Views: 43
Reputation: 323226
Check with
df=df.groupby('A',as_index=False).first()
Out[65]:
A B C D
0 10 100.0 NaN 300.0
1 20 100.0 200.0 400.0
2 30 1.0 NaN 19.0
3 40 NaN 2.0 1.0
Upvotes: 1