22
33import pytest
44
5- from pandas ._config import using_string_dtype
6-
75import pandas .util ._test_decorators as td
86
97import pandas as pd
108
119pa = pytest .importorskip ("pyarrow" )
1210
1311
14- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" )
1512@td .skip_if_no ("pyarrow" , min_version = "14.0" )
16- def test_dataframe_arrow_interface ():
13+ def test_dataframe_arrow_interface (using_infer_string ):
1714 df = pd .DataFrame ({"a" : [1 , 2 , 3 ], "b" : ["a" , "b" , "c" ]})
1815
1916 capsule = df .__arrow_c_stream__ ()
@@ -25,7 +22,15 @@ def test_dataframe_arrow_interface():
2522 )
2623
2724 table = pa .table (df )
28- expected = pa .table ({"a" : [1 , 2 , 3 ], "b" : ["a" , "b" , "c" ]})
25+ expected = pa .table (
26+ {
27+ "a" : [1 , 2 , 3 ],
28+ "b" : pa .array (
29+ ["a" , "b" , "c" ],
30+ pa .large_string () if using_infer_string else pa .string (),
31+ ),
32+ }
33+ )
2934 assert table .equals (expected )
3035
3136 schema = pa .schema ([("a" , pa .int8 ()), ("b" , pa .string ())])
@@ -34,13 +39,20 @@ def test_dataframe_arrow_interface():
3439 assert table .equals (expected )
3540
3641
37- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" )
3842@td .skip_if_no ("pyarrow" , min_version = "15.0" )
39- def test_dataframe_to_arrow ():
43+ def test_dataframe_to_arrow (using_infer_string ):
4044 df = pd .DataFrame ({"a" : [1 , 2 , 3 ], "b" : ["a" , "b" , "c" ]})
4145
4246 table = pa .RecordBatchReader .from_stream (df ).read_all ()
43- expected = pa .table ({"a" : [1 , 2 , 3 ], "b" : ["a" , "b" , "c" ]})
47+ expected = pa .table (
48+ {
49+ "a" : [1 , 2 , 3 ],
50+ "b" : pa .array (
51+ ["a" , "b" , "c" ],
52+ pa .large_string () if using_infer_string else pa .string (),
53+ ),
54+ }
55+ )
4456 assert table .equals (expected )
4557
4658 schema = pa .schema ([("a" , pa .int8 ()), ("b" , pa .string ())])
0 commit comments