Create Pandas dataframe with list as values in rows
simple
pd.DataFrame(
[[[1, 2, 3, 4], [2, 3, 4, 5], [4, 5, 5, 6], [6, 3, 4, 5]],
[[2, 3, 5, 6], [3, 4, 6, 6], [3, 4, 5, 7], [2, 6, 3, 4]],
[[8, 9, 6, 7], [5, 7, 9, 5], [3, 7, 9, 5], [5, 7, 9, 8]]],
columns=list('ABCD')
)
Or
build a Series
with a MultiIndex
and unstack
lst = [
[1, 2, 3, 4],
[2, 3, 4, 5],
[4, 5, 5, 6],
[6, 3, 4, 5],
[2, 3, 5, 6],
[3, 4, 6, 6],
[3, 4, 5, 7],
[2, 6, 3, 4],
[8, 9, 6, 7],
[5, 7, 9, 5],
[3, 7, 9, 5],
[5, 7, 9, 8]]
pd.Series(lst, pd.MultiIndex.from_product([[0, 1, 2], list('ABCD')])).unstack()
A B C D
0 [1, 2, 3, 4] [2, 3, 4, 5] [4, 5, 5, 6] [6, 3, 4, 5]
1 [2, 3, 5, 6] [3, 4, 6, 6] [3, 4, 5, 7] [2, 6, 3, 4]
2 [8, 9, 6, 7] [5, 7, 9, 5] [3, 7, 9, 5] [5, 7, 9, 8]