pydata/pandas — Issue #841: "approximate" datetime reindexing
Author: adamklein
Created: 2012-02-29 17:40:30+00:00
State: open
Labels: datetime, Enhancement

From the mailing list:

It would be nice to have a general, useful algorithm for doing
"approximate" reindexing like you describe. I'm thinking:

def approx_resample(obj, base, multiple, tolerance, offset=0, mode='nearest'):
...

then you would do:

result = approx_resample(df, 'min', 15, 5)

obviously

'min' <=> Minute()

offset would enable you to do like 1, 16, 31, 46 (offset=1) instead of
0, 15, 30, 45

mode parameter would allow you to do other things-- nearest, first,
last, mean of values, or some kind of interpolation method, etc.

to reflect the fact that you don't have some times you would just
dropna in the result-- could make the algo a bit smarter and only
generate dates that are within the tolerance of observed dates
(according to the frequency multiple)