Python Matrix indexes

91 views Asked by At

I have a matrix with 3 dimension:

import numpy as np
a = np.array([[['Mon',18,20,22,17],['Tue',11,18,21,18]],
   [['Wed',15,21,20,19],['Thu',11,20,22,21]],
   [['Fri',18,17,23,22],['Sat',12,22,20,18]]])**

and if I do

print(a[0,1,3]) and print(a[0][1][3])

they return the same result.

but if I do:

print(a[:,1,3])
print(a[:][1][3])

I obtain the following error

> ---------------------------------------------------------------------------
> IndexError  Traceback (most recent call last)
/var/folders/1l/3t6_gr9d461945kx872yt9rm0000gn/T/ipykernel_1070/3758069636.py in <module>
      7 print(np.shape(a))
      8 print((a[:,1,3]))
----> 9 print((a[:][1][3]))
> 
> IndexError: index 3 is out of bounds for axis 0 with size 2

what is the differences between a[:][1][3] and a[:,1,3])?

0

There are 0 answers