I have a Dataframe like:
matrix = [(222, ['A','B','C'], [1,2,3]),
(333, ['A','B','D'], [1,3,5])]
df = pd.DataFrame(matrix, columns=['timestamp', 'variable', 'value'])
timestamp variable value
222 ['A','B','C'] [1,2,3]
333 ['A','B','D'] [1,3,5]
and would like to pivot it so that the timestamp value is kept, the unique values in the variable column become additional columns, and values from value are sorted in the respective columns.
The output should look as follows:
timestamp A B C D
222 1 2 3 nan
333 1 3 nan 5
any help would be greatly appreciated! :)