Angenommen, ich habe diesen:Indizierung eine numpy 2D-Matrix
import numpy as np
N = 5
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])
Nun, ich will manually
zeigen die ids
und scores
jener Schüler, deren Punktzahl mehr als 4,0.
Wie kann ich die folgende Routine arbeiten lassen?
print(students_mat([False, True, False, False, False]))
Fehler
>>> (executing file "arrays.py")
Traceback (most recent call last):
File "D:\Python\arrays.py", line 25, in <module>
print(students_mat([False, True, False, False, False]))
TypeError: 'numpy.ndarray' object is not callable
Sie Indexfelder mit Klammern, nicht Klammern: 'students_mat [[False, True, False, False False]]' – user2357112
Ich glaube, Sie brauchen auch um das in ein numpliges Array umzuwandeln. Es scheint, dass die boolesche Indizierung bei Listen nicht funktioniert. – ayhan
@ user2357112, Programm kompiliert. Aber, gibt falsche Ausgabe. – anonymous