Reputation: 15
Hi I have currently been trying to convert a list of lists of lists into a dataframe. Please see the example below:
data = [[[1, 1, 1], [2, 2, 2], [3, 3, 3]],
[[4, 4], [5, 5], [6, 6]],
[[7], [8], [9]]]
and I would like to have a result like this
1 2 3
1 2 3
1 2 3
4 5 6
4 5 6
7 8 9
Could anyone please give me a suggestion or solution? or is there any package being able to handle this problem?
Upvotes: 1
Views: 86
Reputation: 51175
Using column_stack
:
pd.DataFrame(np.column_stack(data).T)
0 1 2
0 1 2 3
1 1 2 3
2 1 2 3
3 4 5 6
4 4 5 6
5 7 8 9
Upvotes: 1