I'm trying to marge rows from a pandas DF by using a unique key (ID), I've the following initial DF:
| ID | RIGHT | LEFT | CENTER |
|---|---|---|---|
| 1 | 1 | 0 | 0 |
| 2 | 0 | 1 | 0 |
| 2 | 1 | 0 | 0 |
| 3 | 0 | 1 | 0 |
| 3 | 0 | 0 | 1 |
And I wan't to get the following output:
| ID | RIGHT | LEFT | CENTER |
|---|---|---|---|
| 1 | 1 | 0 | 0 |
| 2 | 1 | 1 | 0 |
| 3 | 0 | 1 | 1 |
Right now I'm using the following code but it's not working, I'm just keeping the first row of the ID:
df = df.drop_duplicates(subset=['ID'])
And I'm getting the following output:
| ID | RIGHT | LEFT | CENTER |
|---|---|---|---|
| 1 | 1 | 0 | 0 |
| 2 | 0 | 1 | 0 |
| 3 | 0 | 1 | 0 |
Thank you for your help!