I've a DataFrame that looks like this
| Name | Result_cat_1 | Result1 | Result_cat_2 | Result_2 | Result_cat_3 | Result_3 |
|---|---|---|---|---|---|---|
| Andrew | Rock | 12 plays | Paper | 4 plays | Scissors | 45 plays |
| John | Paper | 8 plays | Scissors | 15 plays | Rock | 76 plays |
| Ronald | Scissors | 6 plays | Rock | 3 plays | Paper | 23 plays |
The end result should be like this:
| Name | Rock | Paper | Scissors |
|---|---|---|---|
| Andrew | 12 plays | 4 plays | 45 plays |
| John | 76 plays | 8 plays | 15 plays |
| Ronald | 3 plays | 23 plays | 6 plays |
I've tried
df['Rock'] = df[Result1].where(df[Result_cat_1] == 'Rock')
df['Rock'] = df[Result2].where(df[Result_cat_2] == 'Rock')
df['Rock'] = df[Result3].where(df[Result_cat_3] == 'Rock')
but the column contains only the df[Result_cat_3] overwriting the previous 2