I am trying to fill the dataframe with certain condition but I can not find the appropriate solution. I have a bit larger dataframe bet let's say that my pandas dataframe looks like this:
0 | 1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|---|
0.32 | 0.40 | 0.60 | 1.20 | 3.40 | 0.00 |
0.17 | 0.12 | 0.00 | 1.30 | 2.42 | 0.00 |
0.31 | 0.90 | 0.80 | 1.24 | 4.35 | 0.00 |
0.39 | 0.00 | 0.90 | 1.50 | 1.40 | 0.00 |
And I want to update the values, so that if 0.00 appears once in a row (row 2 and 4) that until the end all the values are 0.00. Something like this:
0 | 1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|---|
0.32 | 0.40 | 0.60 | 1.20 | 3.40 | 0.00 |
0.17 | 0.12 | 0.00 | 0.00 | 0.00 | 0.00 |
0.31 | 0.90 | 0.80 | 1.24 | 4.35 | 0.00 |
0.39 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
I have tried with
for t in range (1,T-1):
data= np.where(df[t-1]==0,0,df[t])
and several others ways but I couldn't get what I want.
Thanks!