Issue
I have a 3 dimensional ndarray and cannot understand the Axis and Shape in the variable explorer of Spyder. Below variable is my 3 dimensional array and I would appreciate if someone can explan the axis and shapes for me:
t = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]
t = np.reshape(t,(4,3,2))
for example when I set the Axis to 0, a 3*2 frame will show up. when I set it to 1, a 4*2 frame will show up and finally when I set the Axis to 2, a 4*3 frame will show up and I am having trouble visualizing them in a 3 dimensional form. PS: I know it sounds completely unprofessional ...
Solution
Axis 0 would list values on y-z plane Axis 1 gives x-z plane values Axis 2 would list values on x-y plane
Index would be the dimension of the third axis whose value is not shown for a given axis.
a=np.ones(90)
a = np.ones(90)
a= a.reshape(9,5,2)
a[0]=2*a[0]
a[:,1,:]=3*a[:,1,:]
a[:,:,1]=7*a[:,:,1]
a.shape
Try this code and see the results with different values. If any index in slicing is -1, it means the value for that index is calculated based on the othee dimensions of the dataframe.
Answered By - Nancy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.