@@ -164,19 +164,26 @@ def test_astype_category_readonly_mask_values(self):
164
164
expected = array ([0 , 1 , 2 ], dtype = "Int64" ).astype ("category" )
165
165
tm .assert_extension_array_equal (result , expected )
166
166
167
- def test_arrow_array_astype_to_categorical_dtype_temporal (self ):
167
+ def test_arrow_array_astype_to_categorical_dtype_date (self ):
168
168
# GH#62051
169
169
pytest .importorskip ("pyarrow" )
170
170
arr = array (
171
171
["2017-01-01" , "2018-01-01" , "2019-01-01" ], dtype = "date32[day][pyarrow]"
172
172
)
173
173
cats = Index (["2017-01-01" , "2018-01-01" , "2019-01-01" ], dtype = "M8[s]" )
174
174
dtype = CategoricalDtype (categories = cats , ordered = False )
175
-
176
175
assert not all (isna (arr .astype (dtype )))
177
176
177
+ arr_index , cats = Index (arr )._maybe_downcast_for_indexing (cats )
178
+ assert cats ._should_compare (arr_index )
179
+
180
+ def test_arrow_array_astype_to_categorical_dtype_timedelta (self ):
181
+ # GH#62051
182
+ pytest .importorskip ("pyarrow" )
178
183
arr = ArrowExtensionArray ._from_sequence (["1h" , "2h" , "3h" ])
179
184
cats = Index (["1h" , "2h" , "3h" ], dtype = "m8[ns]" )
180
185
dtype = CategoricalDtype (cats , ordered = False )
181
-
182
186
assert not all (isna (arr .astype (dtype )))
187
+
188
+ arr_index = cats ._maybe_cast_listlike_indexer (Index (arr ))
189
+ tm .assert_index_equal (arr_index , cats )
0 commit comments