Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Hi I have a question. How does one divide the current row with previous row in Dataiku? For example, let's say I have a column that contains stock prices, and I would like to calculate the change in price by dividing current row with previous row and minusing 1. How does one do that?
Here was how I solved it: I used the "Window" recipe. First, I partitioned by the correct column at which to perform subset operations on. Next, I order column by datetime (if there is one). Finally, I selected "Lag" for the column Price under Aggregations to get the lag. Next, using a "Prepared" recipe and "formula", I divided the current Price column with the newly created "Lag" column to get the change in price as wanted.
Take a look at the window visual recipie.
Training materials that might be helpful can be found here.
https://academy.dataiku.com/data-pipelines/513267
Hope that helps
The idea is that you would order by some value like a trading day. You might group by some other value like a specific stock. Then you would want the lag value from the earlier day's trading. In a separate step, you would then do your arithmetic to get your percent change. Or you might do this in a custom agrigation.
Hope this helps.
Thank you for your answer. I did manage to solve it
Here was how I solved it: I used the "Window" recipe. First, I partitioned by the correct column at which to perform subset operations on. Next, I order column by datetime (if there is one). Finally, I selected "Lag" for the column Price under Aggregations to get the lag. Next, using a "Prepared" recipe and "formula", I divided the current Price column with the newly created "Lag" column to get the change in price as wanted.