How do I change the data so that every single entry in some pandas df column will now show the sum of the last say 4 entries? The first 3 entries can just stay as the cumulative sum, however after the first 3 I want each entry to have a value that was the sum of the last 4 in the original column.
E.g. 1, 2, 3, 4, 5, 2 would become 1, 3 (2+1) 6 (3+2+1), 10 (4+3+2+1), 14 (5+4+3+2), 14 (2+5+4+3)
Thank you.