I have a following array.
a = np.array([[0, 5, 0, 5],
[0, 9, 0, 9]])
>>>a.shape
Out[72]: (2, 4)
>>>np.all(a,axis=0)
Out[69]:
array([False, True, False, True], dtype=bool)
>>>np.all(a,axis=1)
Out[70]:
array([False, False], dtype=bool)
Because axis 0 means the first axis(row-wise) in 2D array,
I expected when np.all(a,axis=0) is given, it checks whether all element is True or not, per every row.
But it seems like checking per column cause it gives output as 4 elements like array([False, True, False, True], dtype=bool).
What am I misunderstanding about np.all functioning?
axis=0is per col for 2D. The axes start from left as 0,1,2, etc.axisargument as the the axis you are collapsing. When you passaxis=0, you are collapsing all of the rows, to one row.