12.11) More Dimensions
For arrays with more dimensions, it can be tricky to keep track of the order of dimensions, so let’s see an example:
>>> B=np.ones((2,3,4)) # 2x3x4 array >>> print B [[[ 1. 1. 1. 1.] [ 1. 1. 1. 1.] [ 1. 1. 1. 1.]] [[ 1. 1. 1. 1.] [ 1. 1. 1. 1.] [ 1. 1. 1. 1.]]]
So here we have 4 columns, 3 rows and two paragraphs if you like, so the order is something like B(paragraph,row,column). The rule is that the columns are always last.
How will the array B look like after these assignments? The result is on the next page.
>>> B[1,2,3]=99.9 >>> B[1,0,1]=55.5 >>> B[0,:,3]=44.4