-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: interchange protocol with nullable datatypes a non-null validity #57665
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 2 commits
3bf21ef
b99da09
9ccec2d
bb0b7fa
8650b6f
4683361
b3af831
54448e1
c56a26c
62fb815
b9c15c6
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 |
---|---|---|
|
@@ -8,7 +8,6 @@ | |
is_ci_environment, | ||
is_platform_windows, | ||
) | ||
import pandas.util._test_decorators as td | ||
|
||
import pandas as pd | ||
import pandas._testing as tm | ||
|
@@ -417,17 +416,35 @@ def test_non_str_names_w_duplicates(): | |
pd.api.interchange.from_dataframe(dfi, allow_copy=False) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"dtype", ["Int8", pytest.param("Int8[pyarrow]", marks=td.skip_if_no("pyarrow"))] | ||
) | ||
def test_nullable_integers(dtype: str) -> None: | ||
def test_nullable_integers() -> None: | ||
Comment on lines
-420
to
+419
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. splitting the pyarrow dtype out of this test so I can xfail it |
||
# https://github.com/pandas-dev/pandas/issues/55069 | ||
df = pd.DataFrame({"a": [1]}, dtype="Int8") | ||
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. Could you include a And parametrize over 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. boolean isn't supported yet, there's a separate issue about that: #55332 sure, I've added a separate test |
||
expected = pd.DataFrame({"a": [1]}, dtype="int8") | ||
result = pd.api.interchange.from_dataframe(df.__dataframe__()) | ||
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
@pytest.mark.xfail(reason="https://github.com/pandas-dev/pandas/issues/57664") | ||
def test_nullable_integers_pyarrow() -> None: | ||
# https://github.com/pandas-dev/pandas/issues/55069 | ||
df = pd.DataFrame({"a": [1]}, dtype=dtype) | ||
df = pd.DataFrame({"a": [1]}, dtype="Int8[pyarrow]") | ||
expected = pd.DataFrame({"a": [1]}, dtype="int8") | ||
result = pd.api.interchange.from_dataframe(df.__dataframe__()) | ||
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
def test_nullable_integers_w_missing_values() -> None: | ||
# https://github.com/pandas-dev/pandas/issues/57643 | ||
pytest.importorskip("pyarrow", "11.0.0") | ||
import pyarrow.interchange as pai | ||
mroeschke marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
df = pd.DataFrame({"a": [1, 2, None]}, dtype="Int64") | ||
result = pai.from_dataframe(df.__dataframe__())["a"] | ||
assert result[0].as_py() == 1 | ||
assert result[1].as_py() == 2 | ||
assert result[2].as_py() is None | ||
|
||
|
||
def test_empty_dataframe(): | ||
# https://github.com/pandas-dev/pandas/issues/56700 | ||
df = pd.DataFrame({"a": []}, dtype="int8") | ||
|
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.
Oh actually. I guess we need a 2.2.2 whatsnew first
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.
ah right, 2.2.1 is already out, sorry about that, thanks for spotting it