1

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?

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.