1

In numpy, is it recommended to create column arrays (2d arrays) rather than 1d arrays? For example, whereas Z = np.zeros((12,)) defines a 1-dimensional list, it might also be preferable to form Z = np.zeros((12,1)).

1
  • 1
    Use the 1-d array by default. Only use the 2-d shape when you know you need it. Commented Jan 9, 2014 at 18:31

1 Answer 1

1

Depends on the use case. Both possibilities exist for a reason: if Z can be a matrix but just happens to have one column, make it a column vector. If Z is always a single vector, make it 1-d unless some operation (or library) requires the other format; 1-d is usually a bit easier to work with.

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.