|
8 | 8 | is_ci_environment, |
9 | 9 | is_platform_windows, |
10 | 10 | ) |
11 | | -import pandas.util._test_decorators as td |
12 | 11 |
|
13 | 12 | import pandas as pd |
14 | 13 | import pandas._testing as tm |
@@ -417,17 +416,35 @@ def test_non_str_names_w_duplicates(): |
417 | 416 | pd.api.interchange.from_dataframe(dfi, allow_copy=False) |
418 | 417 |
|
419 | 418 |
|
420 | | -@pytest.mark.parametrize( |
421 | | - "dtype", ["Int8", pytest.param("Int8[pyarrow]", marks=td.skip_if_no("pyarrow"))] |
422 | | -) |
423 | | -def test_nullable_integers(dtype: str) -> None: |
| 419 | +def test_nullable_integers() -> None: |
| 420 | + # https://github.com/pandas-dev/pandas/issues/55069 |
| 421 | + df = pd.DataFrame({"a": [1]}, dtype="Int8") |
| 422 | + expected = pd.DataFrame({"a": [1]}, dtype="int8") |
| 423 | + result = pd.api.interchange.from_dataframe(df.__dataframe__()) |
| 424 | + tm.assert_frame_equal(result, expected) |
| 425 | + |
| 426 | + |
| 427 | +@pytest.mark.xfail(reason="https://github.com/pandas-dev/pandas/issues/57664") |
| 428 | +def test_nullable_integers_pyarrow() -> None: |
424 | 429 | # https://github.com/pandas-dev/pandas/issues/55069 |
425 | | - df = pd.DataFrame({"a": [1]}, dtype=dtype) |
| 430 | + df = pd.DataFrame({"a": [1]}, dtype="Int8[pyarrow]") |
426 | 431 | expected = pd.DataFrame({"a": [1]}, dtype="int8") |
427 | 432 | result = pd.api.interchange.from_dataframe(df.__dataframe__()) |
428 | 433 | tm.assert_frame_equal(result, expected) |
429 | 434 |
|
430 | 435 |
|
| 436 | +def test_nullable_integers_w_missing_values() -> None: |
| 437 | + # https://github.com/pandas-dev/pandas/issues/57643 |
| 438 | + pytest.importorskip("pyarrow", "11.0.0") |
| 439 | + import pyarrow.interchange as pai |
| 440 | + |
| 441 | + df = pd.DataFrame({"a": [1, 2, None]}, dtype="Int64") |
| 442 | + result = pai.from_dataframe(df.__dataframe__())["a"] |
| 443 | + assert result[0].as_py() == 1 |
| 444 | + assert result[1].as_py() == 2 |
| 445 | + assert result[2].as_py() is None |
| 446 | + |
| 447 | + |
431 | 448 | def test_empty_dataframe(): |
432 | 449 | # https://github.com/pandas-dev/pandas/issues/56700 |
433 | 450 | df = pd.DataFrame({"a": []}, dtype="int8") |
|
0 commit comments