@@ -1034,14 +1034,7 @@ def test_read_use_nullable_types_pyarrow_config(self, pa, df_full):
1034
1034
df ["bool_with_none" ] = [True , None , True ]
1035
1035
1036
1036
pa_table = pyarrow .Table .from_pandas (df )
1037
- expected = pd .DataFrame (
1038
- {
1039
- col_name : pd .arrays .ArrowExtensionArray (pa_column )
1040
- for col_name , pa_column in zip (
1041
- pa_table .column_names , pa_table .itercolumns ()
1042
- )
1043
- }
1044
- )
1037
+ expected = pa_table .to_pandas (types_mapper = pd .ArrowDtype )
1045
1038
# pyarrow infers datetimes as us instead of ns
1046
1039
expected ["datetime" ] = expected ["datetime" ].astype ("timestamp[us][pyarrow]" )
1047
1040
expected ["datetime_with_nat" ] = expected ["datetime_with_nat" ].astype (
@@ -1059,6 +1052,20 @@ def test_read_use_nullable_types_pyarrow_config(self, pa, df_full):
1059
1052
expected = expected ,
1060
1053
)
1061
1054
1055
+ def test_read_use_nullable_types_pyarrow_config_index (self , pa ):
1056
+ df = pd .DataFrame (
1057
+ {"a" : [1 , 2 ]}, index = pd .Index ([3 , 4 ], name = "test" ), dtype = "int64[pyarrow]"
1058
+ )
1059
+ expected = df .copy ()
1060
+
1061
+ with pd .option_context ("mode.dtype_backend" , "pyarrow" ):
1062
+ check_round_trip (
1063
+ df ,
1064
+ engine = pa ,
1065
+ read_kwargs = {"use_nullable_dtypes" : True },
1066
+ expected = expected ,
1067
+ )
1068
+
1062
1069
1063
1070
class TestParquetFastParquet (Base ):
1064
1071
def test_basic (self , fp , df_full ):
0 commit comments