File tree 1 file changed +33
-0
lines changed
pandas/tests/series/methods
1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 16
16
NA ,
17
17
Categorical ,
18
18
CategoricalDtype ,
19
+ DatetimeTZDtype ,
19
20
Index ,
20
21
Interval ,
21
22
NaT ,
@@ -363,6 +364,38 @@ def test_astype_nan_to_bool(self):
363
364
expected = Series (True , dtype = "bool" )
364
365
tm .assert_series_equal (result , expected )
365
366
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
+
366
399
367
400
class TestAstypeString :
368
401
@pytest .mark .parametrize (
You can’t perform that action at this time.
0 commit comments