8

I have some data loaded as a np.ndarray and need to convert it to a np.array.

Is there an easy/quick way of doing this without having to re-load the data in a different way?

All the information I can find in tutorials seems to refer to one type of array or the other, but not how to change data from one to the other.

Simeon Visser
123k18 gold badges192 silver badges185 bronze badges
asked Jul 4, 2012 at 20:06

1 Answer 1

7

They are the same: numpy.array is a function that constructs an object of type numpy.ndarray.

>>> import numpy
>>> numpy.ndarray
<type 'numpy.ndarray'>
>>> numpy.array
<built-in function array>
>>> numpy.array([])
array([], dtype=float64)
>>> isinstance(numpy.array([]), numpy.ndarray)
True
answered Jul 4, 2012 at 20:10
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.