Inqa
Inqa

Reputation: 55

TypeError when calling multidimensional NumPy array by index

I could not make the code look normal...

import numpy as np

test = np.zeros(3,2)

print(test[0])
---------------------------------------------------------------------------
TypeError                                 
Traceback (most recent call last)

<ipython-input-35-81513f7c30bf> in <module>()

      1 import numpy as np

----> 2 test = np.zeros(3,2)

      3 print(test[0])

TypeError: data type not understood

Upvotes: 1

Views: 28

Answers (1)

Mike M&#252;ller
Mike M&#252;ller

Reputation: 85442

Make the shape a tuple:

test = np.zeros((3,2))
print(test[0])

Output:

[ 0.  0.]

Upvotes: 1

Related Questions