-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: add rounding method to DatetimeIndex/TimedeltaIndex #4314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
How should the API look like for this one? Add a It is also not really compatible with the |
no indexes DO have a round method! but prob not checked properly. The numeric indexes (float/int) should support this (it might work already) as its a numpy method. The Timedelta/DatetimeIndex should simply call the new one (which does sensible rounding). Further, the Series.round() ultimately calls e.g.
|
at the moment there is no round method at the index, at least I don't find it. About the |
there WAS a round method prior to 0.15 implicitly as it was an ndarray subclass
|
This does seem like a good idea. |
straightforward too :) |
Very useful. Would we have an option to always round down? I've needed something like postgres' |
note that I had originally implemented this for |
I've been looking into the rounding down part. In theory, I think this might be what Here's what I came up with: def asfreq(dt, freq, how='start'):
resample_how = {'start': 'first', 's': 'first', 'end': 'last', 'e': 'last'}[how]
resampled = pd.Series(t, t).resample(freq, how=resample_how).index
return resampled[resampled.get_indexer(t, method='ffill')] I've been doing this with a combination of |
Yeah I've been doing something similar. Thankfully my data has had a regular interval. |
Yes indeed a good idea! I already wanted to do this for some time, but never found the time .. @shoyer for the rounding down part, can't you also do the same as above, but use floor instead of round:
|
BTW, never heard of |
for a
|
xref #8184
to say round by minute
http://stackoverflow.com/questions/17781159/round-pandas-datetime-index
by hour
#4314
might be simpler to use numpy astype here
http://stackoverflow.com/questions/23315163/merging-two-pandas-timeseries-shifted-by-1-second
The text was updated successfully, but these errors were encountered: