-
Notifications
You must be signed in to change notification settings - Fork 590
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
BUG: Fix pandas backends to have inclusive preceding window bound #2009
Conversation
| @@ -306,11 +310,6 @@ def compute_window_spec_interval(_, expr): | |||
| return pd.tseries.frequencies.to_offset(value) | |||
|
|
|||
|
|
|||
| @compute_window_spec.register(dt.DataType) | |||
| def compute_window_spec_expr(_, expr): | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this function should ever be called as Ibis throws an input exception if preceding is not an integer or an Ibis interval.
|
cc: @jreback @toryhaavik |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
@hjoo Can you change the title to include BUG? |
|
will look |
|
@hjoo about the PR titles you can check here some info #1606 (comment) |
|
@hjoo reasonable to add an I think by default we should actually match pandas behavior, e.g. cc @toryhaavik |
|
@jreback not quite sure I follow. I thought In Ibis, the left row bound is already expected to be a closed bound. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. comments about does this affect other window methods that take preceding. ping on green.
docs/source/release.rst
Outdated
| @@ -7,6 +7,8 @@ Release Notes | |||
| These release notes are for versions of ibis **1.0 and later**. Release | |||
| notes for pre-1.0 versions of ibis can be found at :doc:`/release-pre-1.0` | |||
|
|
|||
| * :release:`1.2.1 <pending>` | |||
| * :bug:`2009` Change window bound behavior in pandas backend to match other backends | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you be a bit more specific here; e.g. when specifying preceding= it did x now does y
| @@ -420,7 +420,8 @@ def trailing_window(preceding, group_by=None, order_by=None): | |||
| preceding : int, float or expression of intervals, i.e. | |||
| ibis.interval(days=1) + ibis.interval(hours=5) | |||
| Int indicates number of trailing rows to include; | |||
| 0 includes only the current row. | |||
| 0 includes only the current row, 1 includes the current row and one | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to update for trailing_range_window as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trailing_range_window is a time range window and not a row-based window so this doesn't apply.
|
if you can also create an issue for discussion about adding a closed= paramter to control the bounds inclusivety. |
|
Created issue #2019 to further discuss |
|
thanks @hjoo |
Fix for issue #2000.
The
precedingargument toibis.window()andibis.trailing_window()is an inclusive preceding bound. Thewindowargument topandas.DataFrame.rolling()is a window size.Currently, pandas backends pass the preceding bound directly as the window size and do not adjust for the inclusive window bounds in ibis.
This PR implements the correct expected behavior and updates the pandas backend tests accordingly.