mardi 21 juillet 2020

Removing an element from multiple lists if certain condition is met

I would like to remove an element from a list if it obeys a certain if condition.

In this particular case I would like to remove an element from multiple lists called EPSILON_I, X_COORDINATE and Z_COORDINATE, if the element in the same position in another list, C_I, is smaller than 0.001.

Any ideas how I can do this? I currently have the following code but it fails with the error: 'TypeError: list indices must be integers or slices, not float'. I am open to any code that works..

for i,j,k,l in zip(X_COORDINATE, Z_COORDINATE, C_I, EPSILON_I) :
if k < 0.001 :
    del EPSILON_I[l]
    del X_COORDINATE[i]
    del Z_COORDINATE[j]
else :
    pass 

Aucun commentaire:

Enregistrer un commentaire