I have a series indexed by timestamp
date value
t1 x1
t2 x2
t3 x3
...
I would like to group the series by hours or days and apply a function group-wise that calculates the ratio
(value of the last timestamp in group - value of the first timestamp in group) / (last timestamp - first timestamp)
How can I do this?