I have a Julia DataFrame with one column being dates and another column being sales data. At each date entry, I want the sum of the total sales in the last 360 days exactly.
Haven’t tried anything successfully so far… Any help much appreciated
I have a Julia DataFrame with one column being dates and another column being sales data. At each date entry, I want the sum of the total sales in the last 360 days exactly.
Haven’t tried anything successfully so far… Any help much appreciated
Copyright © 2021 Jogjafile Inc.
As mentioned in the comment, the question could have included more code to make the problem more obvious and easier to work on. Having said that, here is an example:
The data is generated in
dfand then the rolling sum is calculated with thecombinestatement. Various tweaks might be necessary (does 360 days include the same day or not? Is it 360 days or one calendar year?).P.S. there may be more ways to achieve this goal, and other answers may come up now. For example, there is a package called InMemoryDatasets which might have an easier solution. Also, using only FlexiJoins without DataFrames will probably be faster (see FlexiJoins documentation).