Closed
Description
Consider a time-series, e.g.:
some_quantity
timestamp
2014-10-06 18:00:40.063000-04:00 0.568000
2014-10-06 18:00:41.361000-04:00 3.014770
2014-10-06 18:00:42.896000-04:00 0.878154
2014-10-06 18:00:43.040000-04:00 0.723077
2014-10-06 18:00:44.791000-04:00 0.723077
2014-10-06 18:00:45.496000-04:00 0.309539
2014-10-06 18:00:45.799000-04:00 3.032000
2014-10-06 18:00:47.470000-04:00 3.014770
2014-10-06 18:00:48.092000-04:00 1.584616
and an independent set of timestamps, e.g.:
start_time = datetime.datetime(year = 2014,
month = 10,
day = 6,
hour = 18,
tzinfo = pytz.timezone('US/Eastern')
# Finish 400 seconds later
end_time = start_time + datetime.timedelta(seconds=400)
new_timestamps = pd.date_range(start = start_time,
end = end_time,
freq = '2.5s')
Is there any way to sample the original time-series so that, for each of the new timestamps, we get the sum of values of the original time-series between the new time-stamps?
Another way to put it, is there any way to call resample
by passing it a series of timestamps on which we want to do the sampling? e.g. something like my_series.resample(how='sum', new_timestamps)