I have a dataframe that looks like this
timestamp group score
2020-06-03 09:01:27+00:00 A 13
2020-06-03 09:05:18+00:00 B 14
C 15
2020-06-03 09:05:39+00:00 A 12
2020-06-03 09:05:45+00:00 B 16
2020-06-03 09:07:09+00:00 C 17
2020-06-03 09:08:43+00:00 A 26
I would like to take a rolling window of size three and find the maximum score.
The part I'm struggling with is how to keep the timestamp
and group
information.
The expected output would be:
timestamp group score
2020-06-03 09:05:18+00:00 C 15
C 15
2020-06-03 09:05:45+00:00 B 16
2020-06-03 09:07:09+00:00 C 17
2020-06-03 09:08:43+00:00 A 26
So importantly, the first row in the output is duplicated. Thanks!