-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
DateOffset objects should support rollback on arrays #7449
Comments
You can do this (and its fully vectorized); would be much simpler if Index was mutable, but its not. that said this could easily be inside
|
Very nice! Would it make sense to add a |
http://pandas.pydata.org/pandas-docs/stable/timeseries.html#time-date-components new in 0.14.0 (its in enhnacments a little ways down) |
I see that... I was wondering about |
thats tantamount to supporting |
Not identical, but I often want to apply an offset to a It may reasonable to |
I read back over the datetime documentation today and realized that I missed an obvious solution for my use case: convert to periods with monthly frequency, then back to datetime. This turns out to be much faster, too: def slow_month_start(dates):
offset = pd.tseries.offsets.MonthBegin()
x = (dates - offset).asi8.copy()
x[dates.is_month_start] = dates.asi8[dates.is_month_start]
return pd.DatetimeIndex(x)
def fast_month_start(dates):
return dates.to_period(freq='M').to_timestamp()
Some profiling reveals that there actually is a Python loop involved when subtracting a DateOffset from a DatetimeIndex ( |
ahh great maybe add an example to timeseries.rst and/ cookbook? the apply method in offsets is currently all python code for its flexibility - but could be cythonized in some. cases |
Use case: I would like to be able to rollback a datetime Series or Index, mapping each value to the first day of each month.
I suppose this will probably need Cython to be fast.
Example:
The text was updated successfully, but these errors were encountered: