Numpy
Numpy (46)
Jun's N
2022. 9. 12. 01:59
How to find the position of the first occurrence of a value greater than a given value?
# Input:
url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data'
iris = np.genfromtxt(url, delimiter=',', dtype='object')
# Solution: (edit: changed argmax to argwhere. Thanks Rong!)
np.argwhere(iris[:, 3].astype(float) > 1.0)[0]
# output
50
728x90