Given a numpy
array, I want to slice all rows where the second column is above/equal a certain threshold. Here is my current attempt:
import numpy as np
#inp = input("Input N : ")
#N = float(inp);
N = 5
#ids = np.arange(1, N+1, 1)
#scores = np.random.uniform(low=2.0, high=6.0, size=(N,))
ids = [ 1., 2., 3., 4., 5., ]
scores = [ 3.75320381, 4.32400937, 2.43537978, 3.73691774, 2.5163266, ]
ids_col = ids.copy()
scores_col = scores.copy()
students_mat = np.column_stack([ids_col, scores_col])
accepted = scores_col[scores_col[:]>=4.0]
accepted_std = students_mat[:, accepted]
print(accepted_std)
Error
>>> (executing file "arrays.py")
Traceback (most recent call last):
File "D:\I (Blank Space)\Python\arrays.py", line 19, in <module>
accepted = scores_col[scores_col[:]>=4.0]
TypeError: '>=' not supported between instances of 'list' and 'float'
>>>