File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
pandas/tests/series/methods Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 1616 NA ,
1717 Categorical ,
1818 CategoricalDtype ,
19+ DatetimeTZDtype ,
1920 Index ,
2021 Interval ,
2122 NaT ,
@@ -363,6 +364,38 @@ def test_astype_nan_to_bool(self):
363364 expected = Series (True , dtype = "bool" )
364365 tm .assert_series_equal (result , expected )
365366
367+ @pytest .mark .parametrize (
368+ "dtype" ,
369+ tm .ALL_INT_EA_DTYPES + tm .FLOAT_EA_DTYPES ,
370+ )
371+ def test_astype_ea_to_datetimetzdtype (self , dtype ):
372+ # GH37553
373+ result = Series ([4 , 0 , 9 ], dtype = dtype ).astype (DatetimeTZDtype (tz = "US/Pacific" ))
374+ expected = Series (
375+ {
376+ 0 : Timestamp ("1969-12-31 16:00:00.000000004-08:00" , tz = "US/Pacific" ),
377+ 1 : Timestamp ("1969-12-31 16:00:00.000000000-08:00" , tz = "US/Pacific" ),
378+ 2 : Timestamp ("1969-12-31 16:00:00.000000009-08:00" , tz = "US/Pacific" ),
379+ }
380+ )
381+
382+ if dtype in tm .FLOAT_EA_DTYPES :
383+ expected = Series (
384+ {
385+ 0 : Timestamp (
386+ "1970-01-01 00:00:00.000000004-08:00" , tz = "US/Pacific"
387+ ),
388+ 1 : Timestamp (
389+ "1970-01-01 00:00:00.000000000-08:00" , tz = "US/Pacific"
390+ ),
391+ 2 : Timestamp (
392+ "1970-01-01 00:00:00.000000009-08:00" , tz = "US/Pacific"
393+ ),
394+ }
395+ )
396+
397+ tm .assert_series_equal (result , expected )
398+
366399
367400class TestAstypeString :
368401 @pytest .mark .parametrize (
You can’t perform that action at this time.
0 commit comments