How does the axis parameter from NumPy work?

前端 未结 6 1322
野的像风
野的像风 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:30

    Clearly,

    e.shape == (3, 2, 2)
    

    Sum over an axis is a reduction operation so the specified axis disappears. Hence,

    e.sum(axis=0).shape == (2, 2)
    e.sum(axis=1).shape == (3, 2)
    e.sum(axis=2).shape == (3, 2)
    

提交回复
热议问题