1

I have a dataframe like below:

|  0   |  1    |   2  |
|------|-------|------|
| cats | 987   | pink |
| cats | 22    | pink |
| dogs | 37865 | blue |
| dogs | 373   | blue |
| dogs | 387   | blue |

I'm trying to clean the data and pluck 1 value from column 1 for each pair from columns 0/2. Columns 0 & 2 have duplicate values and should only have 1 row in my dataframe.

What I'd like to reduce the above dataframe is to this

|  0   |  1    |   2  |
|------|-------|------|
| cats | 987   | pink |
| dogs | 37865 | blue |

I've tried selecting unique pairs, but that doesn't really work.

df = df.[0,1].unique()
NothingToSeeHere
  • 2,013
  • 4
  • 23
  • 55

0 Answers0