mercredi 27 juillet 2016

updating prior rows of dataframe conditionally upon current

I have a dataframe (ev), and I would like to read it and whenever the value of the 'trig' column is 64, I need to update the value of the critical column that is 4 rows above, and change it to 999. I tried the code below but it does not change anything, though seems it should work.

for i in range(0,len(ev)):  
    if ev['trig'][i] == 64:
        ev['critical'][i-4] == 999

Aucun commentaire:

Enregistrer un commentaire