How does the axis parameter from NumPy work?

前端 未结 6 1303
野的像风
野的像风 2020-12-02 08:49

Can someone explain exactly what the axis parameter in NumPy does?

I am terribly confused.

I\'m trying to use the function myArray.sum(ax

6条回答
  •  独厮守ぢ
    2020-12-02 09:21

    To understand the axis intuitively, refer the picture below (source: Physics Dept, Cornell Uni)

    The shape of the (boolean) array in the above figure is shape=(8, 3). ndarray.shape will return a tuple where the entries correspond to the length of the particular dimension. In our example, 8 corresponds to length of axis 0 whereas 3 corresponds to length of axis 1.

提交回复
热议问题