Skip to content

Commit

Permalink
Backport PR pandas-dev#60241: TST (string dtype): resolve xfail in ar…
Browse files Browse the repository at this point in the history
…row interface tests
  • Loading branch information
jorisvandenbossche authored and meeseeksmachine committed Nov 8, 2024
1 parent cacd4bb commit a2007e2
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 a2007e2

Please sign in to comment.