0

How to get new array (NEW) from old array (OLD)?

import numpy as np
OLD=np.array([1,4,7,2,5,8,3,6,9])

NEW = [[1,2,3],[4,5,6],[7,8,9]]

NEW = OLD.reshape (???

1 Answer 1

3

Do you mean like this?

>>> import numpy as np
>>> OLD = np.array([1,4,7,2,5,8,3,6,9])
>>> OLD.reshape((3, 3), order='F')
array([[1, 2, 3],
       [4, 5, 6],
       [7, 8, 9]])
Sign up to request clarification or add additional context in comments.

2 Comments

yes,thanks. can you instruct me the meaning of: order='F'? @mgilson
There is a difference between the "C" based ordering and the "F"ortran based ordering. Plug in order='C' for the difference.

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.