I need to add a new feature that aggregates the last 5 data. When it adds 6th data, then it should forget the first data and consider only the last 5 data sets as shown below. Here is the dummy data frame, new_feature is the expected output.
id feature new_feature
1 a a
2 b a+b
3 c a+b+c
4 d a+b+c+d
5 e a+b+c+d+e
6 f b+c+d+e+f
7 g c+d+e+f+g