let's say
df:
user actions
1 A
1 B
1 c
2 A
2 D
3 B
4 C
4 D
I want to convert to this format
new_df:
user action1 action2 action3
1 A B C
2 A D NA
3 B NA NA
4 C D NA
please note that the number of columns in new_df
is equal to the max number of actions among users. it should insert NA if the user is less that max actions.
how can I do it?