File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 44
55import numpy as np
66
7+ from pandas .compat import pa_version_under18p0
78from pandas .compat ._optional import import_optional_dependency
89
910import pandas as pd
@@ -35,7 +36,11 @@ def _arrow_dtype_mapping() -> dict:
3536def arrow_string_types_mapper () -> Callable :
3637 pa = import_optional_dependency ("pyarrow" )
3738
38- return {
39+ mapping = {
3940 pa .string (): pd .StringDtype (na_value = np .nan ),
4041 pa .large_string (): pd .StringDtype (na_value = np .nan ),
41- }.get
42+ }
43+ if not pa_version_under18p0 :
44+ mapping [pa .string_view ()] = pd .StringDtype (na_value = np .nan )
45+
46+ return mapping .get
Original file line number Diff line number Diff line change 66import numpy as np
77import pytest
88
9+ from pandas .compat .pyarrow import pa_version_under18p0
10+
911import pandas as pd
1012import pandas ._testing as tm
1113
@@ -249,6 +251,24 @@ def test_string_inference(self, tmp_path):
249251 )
250252 tm .assert_frame_equal (result , expected )
251253
254+ @pytest .mark .skipif (pa_version_under18p0 , reason = "not supported before 18.0" )
255+ def test_string_inference_string_view_type (self , tmp_path ):
256+ # GH#54798
257+ import pyarrow as pa
258+ from pyarrow import feather
259+
260+ path = tmp_path / "string_view.parquet"
261+ table = pa .table ({"a" : pa .array ([None , "b" , "c" ], pa .string_view ())})
262+ feather .write_feather (table , path )
263+
264+ with pd .option_context ("future.infer_string" , True ):
265+ result = read_feather (path )
266+
267+ expected = pd .DataFrame (
268+ data = {"a" : [None , "b" , "c" ]}, dtype = pd .StringDtype (na_value = np .nan )
269+ )
270+ tm .assert_frame_equal (result , expected )
271+
252272 def test_out_of_bounds_datetime_to_feather (self ):
253273 # GH#47832
254274 df = pd .DataFrame (
You can’t perform that action at this time.
0 commit comments