File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
pandas/tests/arrays/categorical Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 77 CategoricalDtype ,
88 CategoricalIndex ,
99 DatetimeIndex ,
10+ Index ,
1011 Interval ,
1112 NaT ,
1213 Period ,
1314 Timestamp ,
1415 array ,
16+ isna ,
1517 to_datetime ,
1618)
1719import pandas ._testing as tm
20+ from pandas .core .arrays .arrow .array import ArrowExtensionArray
1821
1922
2023class TestAstype :
@@ -160,3 +163,18 @@ def test_astype_category_readonly_mask_values(self):
160163 result = arr .astype ("category" )
161164 expected = array ([0 , 1 , 2 ], dtype = "Int64" ).astype ("category" )
162165 tm .assert_extension_array_equal (result , expected )
166+
167+ def test_arrow_array_astype_to_categorical_dtype_temporal (self ):
168+ arr = array (
169+ ["2017-01-01" , "2018-01-01" , "2019-01-01" ], dtype = "date32[day][pyarrow]"
170+ )
171+ cats = Index (["2017-01-01" , "2018-01-01" , "2019-01-01" ], dtype = "M8[s]" )
172+ dtype = CategoricalDtype (categories = cats , ordered = False )
173+
174+ assert not all (isna (arr .astype (dtype )))
175+
176+ arr = ArrowExtensionArray ._from_sequence (["1h" , "2h" , "3h" ])
177+ cats = Index (["1h" , "2h" , "3h" ], dtype = "m8[ns]" )
178+ dtype = CategoricalDtype (cats , ordered = False )
179+
180+ assert not all (isna (arr .astype (dtype )))
You can’t perform that action at this time.
0 commit comments