GOAL
I want to sum the current row value and the next 2 row value based on ID and time index to the 1st row value. Time index moves forward with a 3day window while the summed values can only have the same ID
The current incorrect functioning
CODE
gr = current_df.groupby("id").rolling('3D').rolling_sum_3.sum()
final_dataframe = pd.DataFrame(gr)
Output
Goal is the following
I have tried
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.