1

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.

2
  • note that numpy arrays are not dynamically growing arrays. So in most cases initializing a completely empty array makes no sense. Commented Feb 24, 2015 at 13:36
  • numpy.empty doesn't fill your array, it just allocates some memory space of appropriate size and keeps that memory "as is". Commented Feb 24, 2015 at 13:42

1 Answer 1

1

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.

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.