Suppose I have the following array of arrays:
Input = np.array([[[[17.63, 0. , -0.71, 29.03],
[17.63, -0.09, 0.71, 56.12],
[ 0.17, 1.24, -2.04, 18.49],
[ 1.41, -0.8 , 0.51, 11.85],
[ 0.61, -0.29, 0.15, 36.75]]],
[[[ 0.32, -0.14, 0.39, 24.52],
[ 0.18, 0.25, -0.38, 18.08],
[ 0. , 0. , 0. , 0. ],
[ 0. , 0. , 0. , 0. ],
[ 0.43, 0. , 0.3 , 0. ]]],
[[[ 0.75, -0.38, 0.65, 19.51],
[ 0.37, 0.27, 0.52, 24.27],
[ 0. , 0. , 0. , 0. ],
[ 0. , 0. , 0. , 0. ],
[ 0. , 0. , 0. , 0. ]]]])
Input.shape
(3, 1, 5, 4)
Together with this Input array is the corresponding Label array for all input, so that:
Label = np.array([0, 1, 2])
Label.shape
(3,)
I need some way to check with all nested arrays of Input, to select ONLY the array with sufficient data points.
By this I mean I want a way to eliminate (or should I say delete) all arrays whose entries of the last 3 rows are all zeros. While doing this also, eliminate the corresponding Label for that array.
Expected output:
Input_filtered
array([[[[17.63, 0. , -0.71, 29.03],
[17.63, -0.09, 0.71, 56.12],
[ 0.17, 1.24, -2.04, 18.49],
[ 1.41, -0.8 , 0.51, 11.85],
[ 0.61, -0.29, 0.15, 36.75]]],
[[[ 0.32, -0.14, 0.39, 24.52],
[ 0.18, 0.25, -0.38, 18.08],
[ 0. , 0. , 0. , 0. ],
[ 0. , 0. , 0. , 0. ],
[ 0.43, 0. , 0.3 , 0. ]]]])
Label_filtered
array([0, 1])
What's the trick that I need?