FlyingPickle
FlyingPickle

Reputation: 1133

python how to make a list into columns in pandas df

I have a list as follows:

[[100,200,300],[10,20,30,40]]

I want to transform each element into a column of a pandas df

The end result looks like:

Col1   Col2    Col3    Col4
100    200     300
10     20      30       40

How can I achieve this? There is a max size of 4 items per list but could be lower.

Upvotes: 0

Views: 55

Answers (1)

Code Different
Code Different

Reputation: 93151

lst = [[100,200,300],[10,20,30,40]]
pd.DataFrame(lst).add_prefix("Col")

Upvotes: 1

Related Questions