Nov-27-2019, 09:07 AM
(This post was last modified: Nov-27-2019, 09:22 AM by StillAnotherDave.)
(Nov-25-2019, 08:45 AM)scidam Wrote:(Nov-24-2019, 10:06 AM)ibreeden Wrote: progresses = np.array([(avg >= 40) and (hard_fail == 0) for (avg, soft_fail, hard_fail) in results])Python loops are slow. It is expected something like this:
progresses = results[(results[:, 0] >= results[:, 0].mean()) * (results[:, 2] != 0)]or
progresses = results[(results[:, 0] >= 40) * (results[:, 2] != 0)]
Many thanks Scidam!! I'll try something along those lines.
(Nov-24-2019, 10:06 AM)ibreeden Wrote: Now it is clear what you want. Line 6 will do the trick.
import numpy as np import matplotlib.pyplot as plt results = np.array([[54, 1, 0], [56, 0, 1], [72, 0, 0], [34, 3, 0]]) names = np.array(['Amy', 'Bob', 'Carol', 'Dave']) progresses = np.array([(avg >= 40) and (hard_fail == 0) for (avg, soft_fail, hard_fail) in results]) print(progresses)
Many thanks Ibreeden
Can any of you help with part © that I mentioned above:
By applying a logical array to select array indices, extract the rows from your array results relating to just the data for the students who have failed. Also extract the names of the students who have failed from names.