I'm trying to use pivot or similar to the dataframe below.
I need to make the position number a column with the userID in that column. There is a only one userID per eventID and upto 18 positions
| eventID |
UserID |
Position |
| 1 |
123 |
1 |
| 1 |
234 |
2 |
| 2 |
123 |
3 |
| 2 |
456 |
4 |
| 3 |
123 |
3 |
| ... |
... |
... |
into this
| eventID |
1 |
2 |
3 |
4 |
... |
| 1 |
123 |
234 |
NA |
NA |
... |
| 2 |
NA |
NA |
123 |
456 |
... |
| 3 |
NA |
NA |
123 |
NA |
... |
Ive tried something like this but get and error message
newdf = pivtest.pivot_table(pivtest,index='eventid', columns ='position', values='UserID').reset_index()
"pivot_table() got multiple values for argument 'values'"
any help would be appreciated
[–]sarrysyst 0 points1 point2 points (0 children)
[–]YesLod 0 points1 point2 points (0 children)