8
votes

I have 2 rows that look like these,

------------------------------
DealName | Target | Acquirer |
-----------------------------
ABC-XYZ  | ABC    | None     |
------------------------------
ABC-XYZ  | None   | XYZ      |
------------------------------

I'm looking to merge them into a single as:

------------------------------
DealName | Target | Acquirer |
-----------------------------
ABC-XYZ  | ABC    | XYZ      |
------------------------------

Not sure how to accomplish this in Pandas. Any pointers will be highly appreciated! Thanks in advance

1

1 Answers

8
votes

IIUC

df.replace('None','').groupby('DealName',as_index=False).agg(''.join)
Out[25]: 
  DealName Target Acquirer
0  ABC-XYZ    ABC      XYZ