-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: Implement interpolation for arrow and masked dtypes #56757
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
Changes from 3 commits
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 |
---|---|---|
|
@@ -498,8 +498,45 @@ def test_interpolate_empty_df(self): | |
assert result is None | ||
tm.assert_frame_equal(df, expected) | ||
|
||
def test_interpolate_ea_raise(self): | ||
@pytest.mark.parametrize( | ||
"dtype", | ||
["Int64", "UInt64", "Int32", "Int16", "Int8", "UInt32", "UInt16", "UInt8"], | ||
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. thx added |
||
) | ||
def test_interpolate_ea(self, dtype): | ||
# GH#55347 | ||
df = DataFrame({"a": [1, None, 2]}, dtype="Int64") | ||
with pytest.raises(NotImplementedError, match="does not implement"): | ||
df.interpolate() | ||
df = DataFrame({"a": [1, None, None, None, 3]}, dtype=dtype) | ||
orig = df.copy() | ||
result = df.interpolate(limit=2) | ||
expected = DataFrame({"a": [1, 1.5, 2.0, None, 3]}, dtype="Float64") | ||
tm.assert_frame_equal(result, expected) | ||
tm.assert_frame_equal(df, orig) | ||
|
||
@pytest.mark.parametrize( | ||
"dtype", | ||
[ | ||
"Float64", | ||
"Float32", | ||
pytest.param("float32[pyarrow]", marks=td.skip_if_no("pyarrow")), | ||
pytest.param("float64[pyarrow]", marks=td.skip_if_no("pyarrow")), | ||
], | ||
) | ||
def test_interpolate_ea_float(self, dtype): | ||
# GH#55347 | ||
df = DataFrame({"a": [1, None, None, None, 3]}, dtype=dtype) | ||
orig = df.copy() | ||
result = df.interpolate(limit=2) | ||
expected = DataFrame({"a": [1, 1.5, 2.0, None, 3]}, dtype=dtype) | ||
tm.assert_frame_equal(result, expected) | ||
tm.assert_frame_equal(df, orig) | ||
|
||
@pytest.mark.parametrize( | ||
"dtype", | ||
["int64", "uint64", "int32", "int16", "int8", "uint32", "uint16", "uint8"], | ||
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. we are also passing in int, which screws with the logic below, I think handling this specifically causes more complexity than simply keeping the explicit list? 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. Ah okay. Sure this is fine for now then |
||
) | ||
def test_interpolate_arrow(self, dtype): | ||
# GH#55347 | ||
pytest.importorskip("pyarrow") | ||
df = DataFrame({"a": [1, None, None, None, 3]}, dtype=dtype + "[pyarrow]") | ||
result = df.interpolate(limit=2) | ||
expected = DataFrame({"a": [1, 1.5, 2.0, None, 3]}, dtype="float64[pyarrow]") | ||
tm.assert_frame_equal(result, expected) |
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.
To confirm, the
na_value
doesn't matter here because of themask
right?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 correct