I would like to use a Pandas Dataframe with a name dfthat has an identifier column and a list column with a variable number of tuples, all tuples are the same length. Looks like that:
ID list
1 [(0,1,2,3),(1,2,3,4),(2,3,4,NaN)]
2 [(Nan,1,2,3),(9,2,3,4)]
3 [(Nan,1,2,3),(9,2,3,4),(A,b,9,c),($,*,k,0)]
And I would like to unzip each list into columns "A", "B", "C", "D" representing fixed positions in each tuple.
The result should look like this:
ID A B C D
1 0 1 2 3
1 1 2 3 4
1 2 3 4 NaN
2 NaN 1 2 3
2 9 2 3 4
3 NaN 1 2 3
3 9 2 3 4
3 A b 9 c
3 $ * k 0
I tried df.apply(pd.Series(list), but could not, because the lenlist items are different for different lines. Somehow you need to unzip columns and transpose by ID?