Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
In Python we can initialise an array with [[]]. But how to initialise a Numpy array without using numpy.zeros, numpy.ones & numpy.empty ? I don't want to use these functions because it fills in my Numpy array.
[[]]
numpy.zeros
numpy.ones
numpy.empty
All the lack of sense in your question aside (Numpy arrays are statically sized on creation),
numpy.ndarray((dim1,dim2,...))
will create a dim1 x dim2 (x dimN) array and skip initialization.
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
numpy.emptydoesn't fill your array, it just allocates some memory space of appropriate size and keeps that memory "as is".