'Use previous cell value from the same column if an event is not present in different column Pandas
I am going through a time series data base in pandas. When an event happens I want the column I am calculating to store the date from another column. If the event is not present I want it to use whatever was in the cell above in the same column. I have tried the following but I cannot get it to work
DB['TimeFlag'] = np.where(DB['Event'] == 10,DB['Time'],DB['TimeFlag'].shift())
I understand it is referencing itself, but its referencing a cell that should have already been calculated. This feels like there should be a very simple solution but I cannot find one. It is very easy to do in excel and I included a visual of what I want the code to do. Any suggestions?

Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
