samedi 27 octobre 2018

Inserting a conditional into a function

This is my function

def sum_ME(data, i, col_X='X', col_Y='Y', col_C='CCC'):
            return  (( (abs(data.iloc[get_ME(i, len(data))][col_X] - data.iloc[i,3]))**2+
           (abs(data.iloc[get_ME(i, len(data))][col_Y] - data.iloc[i,4]))**2 )**0.5).sum()

I'd like to insert a condition, that these values should be sum() only when data.iloc[get_neighbors100k2(i, len(data))][col_C] > 0. I tried with np.where, but it returns a list and not a single value in the end. Any ideas?

Aucun commentaire:

Enregistrer un commentaire