@@ -164,19 +164,26 @@ def test_astype_category_readonly_mask_values(self):
164164 expected = array ([0 , 1 , 2 ], dtype = "Int64" ).astype ("category" )
165165 tm .assert_extension_array_equal (result , expected )
166166
167- def test_arrow_array_astype_to_categorical_dtype_temporal (self ):
167+ def test_arrow_array_astype_to_categorical_dtype_date (self ):
168168 # GH#62051
169169 pytest .importorskip ("pyarrow" )
170170 arr = array (
171171 ["2017-01-01" , "2018-01-01" , "2019-01-01" ], dtype = "date32[day][pyarrow]"
172172 )
173173 cats = Index (["2017-01-01" , "2018-01-01" , "2019-01-01" ], dtype = "M8[s]" )
174174 dtype = CategoricalDtype (categories = cats , ordered = False )
175-
176175 assert not all (isna (arr .astype (dtype )))
177176
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" )
178183 arr = ArrowExtensionArray ._from_sequence (["1h" , "2h" , "3h" ])
179184 cats = Index (["1h" , "2h" , "3h" ], dtype = "m8[ns]" )
180185 dtype = CategoricalDtype (cats , ordered = False )
181-
182186 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