2
2
3
3
import pytest
4
4
5
- from pandas ._config import using_string_dtype
6
-
7
5
import pandas .util ._test_decorators as td
8
6
9
7
import pandas as pd
10
8
11
9
pa = pytest .importorskip ("pyarrow" )
12
10
13
11
14
- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" )
15
12
@td .skip_if_no ("pyarrow" , min_version = "14.0" )
16
- def test_dataframe_arrow_interface ():
13
+ def test_dataframe_arrow_interface (using_infer_string ):
17
14
df = pd .DataFrame ({"a" : [1 , 2 , 3 ], "b" : ["a" , "b" , "c" ]})
18
15
19
16
capsule = df .__arrow_c_stream__ ()
@@ -25,7 +22,8 @@ def test_dataframe_arrow_interface():
25
22
)
26
23
27
24
table = pa .table (df )
28
- expected = pa .table ({"a" : [1 , 2 , 3 ], "b" : ["a" , "b" , "c" ]})
25
+ string_type = pa .large_string () if using_infer_string else pa .string ()
26
+ expected = pa .table ({"a" : [1 , 2 , 3 ], "b" : pa .array (["a" , "b" , "c" ], string_type )})
29
27
assert table .equals (expected )
30
28
31
29
schema = pa .schema ([("a" , pa .int8 ()), ("b" , pa .string ())])
@@ -34,13 +32,13 @@ def test_dataframe_arrow_interface():
34
32
assert table .equals (expected )
35
33
36
34
37
- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" )
38
35
@td .skip_if_no ("pyarrow" , min_version = "15.0" )
39
- def test_dataframe_to_arrow ():
36
+ def test_dataframe_to_arrow (using_infer_string ):
40
37
df = pd .DataFrame ({"a" : [1 , 2 , 3 ], "b" : ["a" , "b" , "c" ]})
41
38
42
39
table = pa .RecordBatchReader .from_stream (df ).read_all ()
43
- expected = pa .table ({"a" : [1 , 2 , 3 ], "b" : ["a" , "b" , "c" ]})
40
+ string_type = pa .large_string () if using_infer_string else pa .string ()
41
+ expected = pa .table ({"a" : [1 , 2 , 3 ], "b" : pa .array (["a" , "b" , "c" ], string_type )})
44
42
assert table .equals (expected )
45
43
46
44
schema = pa .schema ([("a" , pa .int8 ()), ("b" , pa .string ())])
0 commit comments