How to resample timedeltas?
pandas, python
Solution
You can use `groupby` with `time // period` to do this:
import pandas as pd
import numpy as np
t = np.random.rand(10000)*3600
t.sort()
v = np.random.rand(10000)
df = pd.DataFrame({"time":t, "value":v})
period = 5*60
s = df.groupby(df.time // period).value.mean()
s.index *= period
Problem
I have been running an experiment that outputs data with two columns: - seconds since start of experiment (float) - a measurement. (float) I would now like to load this into Pandas to resample and plot the measurements. I've done this before, but those times my timestamps have been since epoch or in datetime (YYY-MM-DD HH:mm:ss) format. If I'm loading my first column as integers I'm unable to do ``` data.resample('5Min', how='mean') ``` . It also does not seem possible if I'd convert my first column to `timedelta(seconds=...)`. My question is, is it possible to resample this data without subverting to epoch conversion?