I've been struggling with a problem for a while and haven't been able to find something similar elsewhere. I'm pretty new to Python so appologies if this is pretty straight forward.
So I have a series that I put into a pandas df: series_ = [0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 4, 0, 0] df = pd.DataFrame(series_, columns = ['Values'])
The series can have two 'signal values': Every time the series value is 1, I want the corresponding value to be 'YES' If the value is 4, it should be 'NO'.
When the series is not 1 or 4, it should replicate the previous signal value (either 'YES' or 'NO') until the next signal value. I sadly can't find a formula that fills up these empty spots.
So what I currently have is my series ('Values') and the translation of these signal values in the column ('Modified'). I am trying to find a formula that will get me the column ('Expected'), a formula which basically replaces the 'UNDECLARED' values with either 'YES' or 'NO' based on the last available signal value. You can see this in the image I posted below.
Would appreciate all help!
Thanks in advance.