Dec-08-2022, 07:42 PM
You can shift the days column.
import pandas as pd df = pd.DataFrame({"Count":range(5)}) df[Shifted'] = df['Count'].shift(1) print(df)
Output: Count Shifted
0 0 NaN
1 1 0.0
2 2 1.0
3 3 2.0
4 4 3.0
Then you could use the shifted column in your function