Suppose I have a 3D numpy array like this:
data = np.array([[[1,2,3,4],[1,2.5,3,5]],
[[116,230,450,430],[80,100,300,320]],
[[60,100,120,80],[50,80,100,90]]])
How can I simply extract from it a 3D numpy array of same shape with a condition on axis 0, for example selecting those "rows" for which axis 0 < 3? A naïve way would be
data[data[0]<3]
But this fails:
IndexError: boolean index did not match indexed array along dimension 0; dimension is 3 but corresponding boolean dimension is 2