Q:

Numpy array all and any operation with combination in 3d array

I'm very new to numpy. I have an array like this and want to apply some operations on it.
It's easy in 2d array, lots of example are there but won't any such in 3d array.
arr = np.array([[[ True, True, False, True],[False, False, True, False],[False, False, False, False], [False, False, False, False],[False, False, True, False]],[[False, False, False, False], [True, True, True, True], [False, False, False, False], [False, False, False, False], [True, True, True, True] ], [[False, False, False, False], [False, False, False, False], [True, True, True, True], [False, False, False, False], [False, False, False, False] ] ])

If after applying np.all in the inner arrays the result would be: [[False, False, False, False, False], [False, True, False, False, True], [False, False, True, False, False]]
Then after np.any result would be: [False, True, True]
What, I mean is to get the overall index of array where any of the all 1d array values are true. Like in my certain case it should return index first and second, as at first index the sub first index and sub fourth index of array all values true and in second index sub second index all array values are true while in zero'th index not a single array whose all value are true.
What I've done so far is
np.all(np.any(arr, axis=1), axis=1)
             OR
np.any(np.all(arr, axis=1), axis=1)

But both are not fruitfull, yes ,I can solve by comprehension but don't want any type looping which is gonna be my last option.

A:

I think the issue comes from confusion in the axis handling.
As a rule of thumb, you can consider that the innermost brackets contain data of the highest dimension.
In your example, if you type arr.shape in your interpreter it will return the following tuple (3, 5, 4) which represent the size of arr in each dimension. If you now do the same with the expected result of the first operation you mentioned in your question you'll get (3, 5), so it looks like you (sort of speak) want to project the data of the highest dimension (i.e. axis=2) to the other axis. Same thing for the next operation except that the highest dimension is now axis=1.
To conclude, the following line would do the job np.any(np.all(arr, axis=2), axis=1).

