0

I have a dataframe with a single columns, each cell is a list with different len, the max len is 5:

df =    0
    [0, 1, 2]
    [0, 4, 6, 9, 11]
    [3]
    [3, 5]

And I want to change it to a dataframe, where I have 5 columns, with the corresponding value from the list and nan if the list was shorter than 4:

df = C1 C2  C3  C4  C5
     0   1  2  nan nan
     0   4  6  9   11
     3  nan nan nan nan
     3   5  nan nan nan

What is the best way to do so?

okuoub
  • 716
  • 6
  • 19
  • 52

0 Answers0