How to shift data in a column

Zaman
Zaman Registered Posts: 2 ✭✭

I have a main question and as part of my solution to it I have a follow up question:
Main question:

I have a column in my time series data (let's call it status) that is populated with on/ off binary data.

I need to find a way to create a column to count the days since last time status was on. so basically when the status is on the counter sets to zero and for all the off statuses after, the counter will count the days and resets to zero when status is on next. I know how I can do it with a for loop in my dataframe if I was using pandas. but I don't know how to do it in dataiku.

Follow up question:

As part of the way I am thinking to do it is to use the formula for a cell in the prepare recipe. but for this I need to know the status of last day in the status column. so I basically need to shift the status column by one day to be able to get that as part of my (def process(row)) function code.

Operating system used: Windows

Answers

Setup Info
    Tags
      Help me…