-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
BUG: rolling with Int64 #43174
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: rolling with Int64 #43174
Changes from 3 commits
f84c520
bc4a45e
57b0ceb
77416cc
3594d79
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
import pytest | ||
|
||
from pandas import ( | ||
NA, | ||
DataFrame, | ||
Series, | ||
) | ||
|
@@ -76,6 +77,14 @@ def test_series_dtypes(method, data, expected_data, coerce_int, dtypes, min_peri | |
tm.assert_almost_equal(result, expected) | ||
|
||
|
||
def test_series_nullable_int(any_signed_int_ea_dtype): | ||
# GH 43016 | ||
s = Series([0, 1, NA], dtype=any_signed_int_ea_dtype) | ||
result = s.rolling(2).mean() | ||
expected = Series([np.nan, 0.5, np.nan]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't we actually replace and use pd.NA as the output? or is this too big of a change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally, but currently all rolling/expanding/ewm results always return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, do we have an issue about this? we should make this change in 1.4 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm no was speaking about supporting pd.NA specifically (i think rolling_apply is totally fine) if you can add one There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I modified that issue to generally support same input/output dtypes (which include ExtensionDtypes that support pd.NA) |
||
tm.assert_series_equal(result, expected) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"method, expected_data, min_periods", | ||
[ | ||
|
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.
im really not sure about this. ensure_foo is fast ATM, plus this introduces circular dependency
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.
Do you think
ensure_foo
should not be used directly on ExtentionArrays i.e.ensure_foo(arr.to_numpy(...))
?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 guess. mainly i think that pd.NA is way more trouble than its worth
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.
hmm i did request this, but agree the performance tradeoff might not be worthit.
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 think maybe making an ensure_*_with_na is prob better here (and make it the caller responsible if we have an EA)
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 went with @jbrockmendel's original
isinstance
check instead for now. For theensure_foo_with_na
feature, probably should be another issue to discuss because it would be potentially useful anywhereensure_foo
is called.