Home > Enterprise >  Numpy shape function for single dimension array
Numpy shape function for single dimension array

Time:09-10

I've started to learn NumPy, when I create an array and then invoke the .shape function, I understand how it works for most cases. However, the result does not make sense to me for a single-dimensional array. Can someone please explain the outcome?

array = np.array([4,5,6])
print(array.shape)

The outcome is (3,)

CodePudding user response:

Output tulpe of ints in the "np.shape" function gives the lengths of the corresponding array dimension, and this tuple will be (n,m), in which n and m indicate row and columns, respectively. For a single dimension array, this Tuple will be just (n,), in which n indicates the number of array elements.

  • Related