3

A slight variant to this question: Pandas split column of lists into multiple columns

Given a dataframe:

col1
[0, 1, 2]
[0, 1]
[0, 1, 2, 3, 4, 5, 6]
[0, 1, 2, 3]

How can I convert this into a dataframe with columns equal to the maximum length?

col1 col2 col3 col4 col5 col6 col7
0    1    2 
0    1 
0    1    2    3    4    5    6
0    1    2    3 
Thiebout
  • 171
  • 3
  • 15

1 Answers1

3

Using pandas DataFrame re-create you df

pd.DataFrame(df.col1.values.tolist())
BENY
  • 317,841
  • 20
  • 164
  • 234