mardi 22 janvier 2019

NP where and if statment conditions

I am currently having a problem understanding np.where in relation to if statements. (https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.where.html) I have heard of it being more efficient. I am trying to get a better understanding of the np.where function but I havent found any examples that are making it clear. This is the if statement I really want to convert, can anyone assist? When you convert this can you give some more conditional examples perhaps. Would numpy conditional statements work better if np.where isn't a probably solution.

if salary <= 6000 and values > 230:
            true_list = true_list + flat_list

Its just appending a list. If you cant do it this way and it needs to be a function it could be np.append or np.concatenate.

End all be all if non of this applies and I have benn thinking totally the wrong way I'm simply looking for a numpy way to do if statements more efficiently(faster).

Aucun commentaire:

Enregistrer un commentaire