-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Handling a CustomBusinessDay in time-based .rolling() #13969
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
You could probably build a second version of this class that handled an arbitrary offset object rather than a fixed window, although it wouldn't be performant, as there would have to be a ton of calls back into python space. Unless there's some trick I'm not thinking of. There was an issue about cythonized offsets, #11214, and I started a proof of concept, but never went any further with it. |
As of now, because offset-based rolling windows are based on converting to nanoseconds (as we are discussing in #13968), which non-fixed frequencies do not support — the This reaffirms my impression that the whole architecture around |
Actually, this isn't as bad as I was thinking. It's be almost like resampling, the one expensive op you'd have to do is generate the range of anchored dates. Then you'd just need a cython function that generates window edges from that range and the frame's index. |
this is actually pretty easy. the point of Once you have this window indexer (and this is pretty cheap to create), then rolling is the same. The current logic assumes a fixed differential indexer (e.g. it has a constant period regardless of the point in time). |
I think this issue can be closed as the VariableOffsetWindowIndexer was added to handle non-fixed offsets. https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.api.indexers.VariableOffsetWindowIndexer.html |
Starting with 10 business days following Christmas Eve:
I can compute the three-day sum of the values with just:
But this is purely in terms of Gregorian calendar days, not the business calendar days that I had created the DataFrame with.
I can easily compute
though I get a performance warning:
But I can't just pass this offset directly:
I would like to be able to handle a
CustomBusinessDay
in.rolling()
. (Because the DataFrame may come from any source, it would be easier to just pass theDateOffset
object to.rolling()
instead of using anything specific to the DataFrame's index.)I know that the
freq
parameter was deprecated in 0.18, though 0.19 kinda brings this back inwindow
. Is there an intrinsic reasonwindow
can't handle aCustomBusinessDay
?The text was updated successfully, but these errors were encountered: