Skip to content

Commit

Permalink
Backport PR #60241 on branch 2.3.x (TST (string dtype): resolve xfail…
Browse files Browse the repository at this point in the history
… in arrow interface tests) (#60248)

Backport PR #60241: TST (string dtype): resolve xfail in arrow interface tests

Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
  • Loading branch information
meeseeksmachine and jorisvandenbossche authored Nov 8, 2024
1 parent 9465bf1 commit 4527585
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions pandas/tests/frame/test_arrow_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@

import pytest

from pandas._config import using_string_dtype

import pandas.util._test_decorators as td

import pandas as pd

pa = pytest.importorskip("pyarrow")


@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
@td.skip_if_no("pyarrow", min_version="14.0")
def test_dataframe_arrow_interface():
def test_dataframe_arrow_interface(using_infer_string):
df = pd.DataFrame({"a": [1, 2, 3], "b": ["a", "b", "c"]})

capsule = df.__arrow_c_stream__()
Expand All @@ -25,7 +22,8 @@ def test_dataframe_arrow_interface():
)

table = pa.table(df)
expected = pa.table({"a": [1, 2, 3], "b": ["a", "b", "c"]})
string_type = pa.large_string() if using_infer_string else pa.string()
expected = pa.table({"a": [1, 2, 3], "b": pa.array(["a", "b", "c"], string_type)})
assert table.equals(expected)

schema = pa.schema([("a", pa.int8()), ("b", pa.string())])
Expand All @@ -34,13 +32,13 @@ def test_dataframe_arrow_interface():
assert table.equals(expected)


@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
@td.skip_if_no("pyarrow", min_version="15.0")
def test_dataframe_to_arrow():
def test_dataframe_to_arrow(using_infer_string):
df = pd.DataFrame({"a": [1, 2, 3], "b": ["a", "b", "c"]})

table = pa.RecordBatchReader.from_stream(df).read_all()
expected = pa.table({"a": [1, 2, 3], "b": ["a", "b", "c"]})
string_type = pa.large_string() if using_infer_string else pa.string()
expected = pa.table({"a": [1, 2, 3], "b": pa.array(["a", "b", "c"], string_type)})
assert table.equals(expected)

schema = pa.schema([("a", pa.int8()), ("b", pa.string())])
Expand Down

0 comments on commit 4527585

Please sign in to comment.