0

I have a dataframe, where each row describe a matrix (3,3):

enter image description here

I transformed this dataframe in multiple matrices, to do some matrices operations with them. I used the code:

df.to_numpy().reshape(-1,3,3)

Which returned:

enter image description here

This is exactly what I wanted but, after finished the operations with the matrices, I need to transform all of these matrices in the original form of the dataframe, like in the first image. How can I do this? There's some analogue function to .to_numpy()? I tried pd.DataFrame(array) but don't worked.

d = pd.DataFrame(array)
ValueError: Must pass 2-d input

1 Answer 1

1

Try:

array_2d = array.reshape((-1, 9))
d = pd.DataFrame(array_2d)
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.