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,15 @@ 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
+ 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
+ )
29
34
assert table .equals (expected )
30
35
31
36
schema = pa .schema ([("a" , pa .int8 ()), ("b" , pa .string ())])
@@ -34,13 +39,20 @@ def test_dataframe_arrow_interface():
34
39
assert table .equals (expected )
35
40
36
41
37
- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" )
38
42
@td .skip_if_no ("pyarrow" , min_version = "15.0" )
39
- def test_dataframe_to_arrow ():
43
+ def test_dataframe_to_arrow (using_infer_string ):
40
44
df = pd .DataFrame ({"a" : [1 , 2 , 3 ], "b" : ["a" , "b" , "c" ]})
41
45
42
46
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
+ )
44
56
assert table .equals (expected )
45
57
46
58
schema = pa .schema ([("a" , pa .int8 ()), ("b" , pa .string ())])
0 commit comments