I have an array that looks like such:
import numpy as np
z=np.random.randint(101,size=(5,3))
array([[41, 98, 63],
[61, 65, 66],
[21, 3, 90],
[53, 60, 26],
[60, 18, 19]])
I want to return values in the second column greater than 25, such as my answer will be:
array([[98],
[65],
[60]])
I tried to create a condition as such:
condition = z[:,1:2] > 25
but when I tried to run:
z[condition]
I get an error
/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:1: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use
arr[tuple(seq)]
instead ofarr[seq]
. In the future this will be interpreted as an array index,arr[np.array(seq)]
, which will result either in an error or a different result."""Entry point for launching an IPython kernel. --------------------------------------------------------------------------- IndexError Traceback (most recent call last) in () ----> 1 z[condition]
IndexError: boolean index did not match indexed array along dimension 1; dimension is 3 but the corresponding boolean dimension is 1
Can someone help, please?