-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: RollingGroupBy.quantile
ignores interpolation
keyword argument
#29567
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: RollingGroupBy.quantile
ignores interpolation
keyword argument
#29567
Conversation
RollingGroupBy.quantile
ignores interpolation
keyword argume…RollingGroupBy.quantile
ignores interpolation
keyword argument
Hello all! My build failed and threw the following error during CI:
My changes didn't touch the reader / parser part of the codebase, so I'm wondering if this problem crept into the build from elsewhere? Any suggestions for what I can do? |
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.
Looks pretty good. Can you try merging master and pushing again? I think should fix your CI issues
pandas/tests/window/test_grouper.py
Outdated
result = r.quantile(0.5) | ||
expected = g.apply(lambda x: x.rolling(4).quantile(0.5)) | ||
tm.assert_frame_equal(result, expected) | ||
for f in ["linear", "lower", "higher", "midpoint", "nearest"]: |
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.
Either here or in a follow up could you parametrize this test with these values rather than the loop within?
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 u make this a separate test and parmetrize
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.
Yes, I think I can handle that here - working on it now.
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 wrote a new test called test_rolling_quantile
and parametrized the interpolation
argument as requested, but unfortunately it looks as though most of the tests in this file have broken since I merged in master. To test, I checked out the upstream master branch, rebuilt my conda environment from scratch, and ran the tests there. 10 of the tests failed, including test_rolling
(stack trace below). Is this a known issue?
self = <pandas.tests.window.test_grouper.TestGrouperGrouping object at 0x116432208>
def test_rolling(self):
g = self.frame.groupby("A")
r = g.rolling(window=4)
for f in ["sum", "mean", "min", "max", "count", "kurt", "skew"]:
> result = getattr(r, f)()
test_grouper.py:64:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../core/window/rolling.py:1870: in sum
return super().sum(*args, **kwargs)
../../core/window/rolling.py:1245: in sum
return self._apply("roll_sum", "sum", **kwargs)
../../core/window/common.py:81: in _apply
return self._groupby.apply(f)
../../core/groupby/groupby.py:718: in apply
result = self._python_apply_general(f)
../../core/groupby/groupby.py:734: in _python_apply_general
keys, values, mutated = self.grouper.apply(f, self._selected_obj, self.axis)
../../core/groupby/ops.py:171: in apply
result_values, mutated = splitter.fast_apply(f, group_keys)
../../core/groupby/ops.py:904: in fast_apply
return libreduction.apply_frame_axis0(sdata, f, names, starts, ends)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> ???
E AttributeError: 'Int64Index' object has no attribute '_has_complex_internals'
pandas/_libs/reduction.pyx:519: AttributeError
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.
Oops, @WillAyd's suggestion to rebuild the Cython extensions was correct. The tests are now passing; I'm going to push my changes shortly.
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.
The change is pushed - let me know if that's different from what you had in mind!
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.
this is including lots of other changes, can you merge master
Oops, I think I rebased by accident instead of merging, give me a moment to fix! |
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.
no need to squash ; we do on merge
doc/source/whatsnew/v1.0.0.rst
Outdated
@@ -436,6 +436,7 @@ Groupby/resample/rolling | |||
- Bug in :meth:`DataFrame.groupby` not offering selection by column name when ``axis=1`` (:issue:`27614`) | |||
- Bug in :meth:`DataFrameGroupby.agg` not able to use lambda function with named aggregation (:issue:`27519`) | |||
- Bug in :meth:`DataFrame.groupby` losing column name information when grouping by a categorical column (:issue:`28787`) | |||
- Bug in :meth:`RollingGroupby.quantile` ignoring ``interpolation`` keyword argument (:issue:`28779`) |
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 will render, can u see how we reference rolling in other notes
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.
Sure, I'll find another example in the notes and imitate it.
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 changed the reference to DataFrameGroupBy.rolling().quantile()
, similarly to the reference to DataFrameGroupBy.rolling().apply()
here: https://pandas.pydata.org/pandas-docs/version/0.23.4/whatsnew.html#groupby-resample-rolling. Hopefully that will work better?
pandas/tests/window/test_grouper.py
Outdated
result = r.quantile(0.5) | ||
expected = g.apply(lambda x: x.rolling(4).quantile(0.5)) | ||
tm.assert_frame_equal(result, expected) | ||
for f in ["linear", "lower", "higher", "midpoint", "nearest"]: |
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 u make this a separate test and parmetrize
previously in test_rolling
Try rebuilding the Cython extensions via python setup.py build_ext —inplace
…Sent from my iPhone
On Nov 17, 2019, at 8:52 AM, Paul Siegel ***@***.***> wrote:
@pwsiegel commented on this pull request.
In pandas/tests/window/test_grouper.py:
> @@ -69,9 +68,10 @@ def test_rolling(self):
expected = g.apply(lambda x: getattr(x.rolling(4), f)(ddof=1))
tm.assert_frame_equal(result, expected)
- result = r.quantile(0.5)
- expected = g.apply(lambda x: x.rolling(4).quantile(0.5))
- tm.assert_frame_equal(result, expected)
+ for f in ["linear", "lower", "higher", "midpoint", "nearest"]:
I wrote a new test called test_rolling_quantile and parametrized the interpolation argument as requested, but unfortunately it looks as though most of the tests in this file have broken since I merged in master. To test, I checked out the upstream master branch, rebuilt my conda environment from scratch, and ran the tests there. 10 of the tests failed, including test_rolling (stack trace below). Is this a known issue?
`self = <pandas.tests.window.test_grouper.TestGrouperGrouping object at 0x116432208>
def test_rolling(self):
g = self.frame.groupby("A")
r = g.rolling(window=4)
for f in ["sum", "mean", "min", "max", "count", "kurt", "skew"]:
result = getattr(r, f)()
test_grouper.py:64:
../../core/window/rolling.py:1870: in sum
return super().sum(*args, **kwargs)
../../core/window/rolling.py:1245: in sum
return self._apply("roll_sum", "sum", **kwargs)
../../core/window/common.py:81: in _apply
return self._groupby.apply(f)
../../core/groupby/groupby.py:718: in apply
result = self._python_apply_general(f)
../../core/groupby/groupby.py:734: in _python_apply_general
keys, values, mutated = self.grouper.apply(f, self._selected_obj, self.axis)
../../core/groupby/ops.py:171: in apply
result_values, mutated = splitter.fast_apply(f, group_keys)
../../core/groupby/ops.py:904: in fast_apply
return libreduction.apply_frame_axis0(sdata, f, names, starts, ends)
???
E AttributeError: 'Int64Index' object has no attribute '_has_complex_internals'
pandas/_libs/reduction.pyx:519: AttributeError
`
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
test from `test_expanding`
consistent with similar bugs
thanks @pwsiegel |
RollingGroupBy.quantile
ignoresinterpolation
argument #28779black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff