@@ -255,7 +255,6 @@ def test_to_datetime_format_YYYYMMDD_with_none(self, input_s):
255
255
def test_to_datetime_format_YYYYMMDD_overflow (self , input_s , expected ):
256
256
# GH 25512
257
257
# format='%Y%m%d', errors='coerce'
258
- # expected = expected.dt.as_unit("ns")
259
258
result = to_datetime (input_s , format = "%Y%m%d" , errors = "coerce" )
260
259
tm .assert_series_equal (result , expected )
261
260
@@ -277,7 +276,6 @@ def test_to_datetime_format_YYYYMMDD_overflow(self, input_s, expected):
277
276
)
278
277
def test_to_datetime_with_NA (self , data , format , expected ):
279
278
# GH#42957
280
- # expected = expected.as_unit("ns")
281
279
result = to_datetime (data , format = format )
282
280
tm .assert_index_equal (result , expected )
283
281
@@ -494,7 +492,7 @@ def test_to_datetime_format_weeks(self, value, fmt, expected, cache):
494
492
def test_to_datetime_parse_tzname_or_tzoffset (self , fmt , dates , expected_dates ):
495
493
# GH 13486
496
494
result = to_datetime (dates , format = fmt )
497
- expected = Index (expected_dates ) # .as_unit("ns")
495
+ expected = Index (expected_dates )
498
496
tm .assert_equal (result , expected )
499
497
500
498
@pytest .mark .parametrize (
@@ -554,7 +552,7 @@ def test_to_datetime_parse_tzname_or_tzoffset_different_tz_to_utc(self):
554
552
fmt = "%Y-%m-%d %H:%M:%S %z"
555
553
556
554
result = to_datetime (dates , format = fmt , utc = True )
557
- expected = DatetimeIndex (expected_dates ) # .as_unit("ns")
555
+ expected = DatetimeIndex (expected_dates )
558
556
tm .assert_index_equal (result , expected )
559
557
560
558
@pytest .mark .parametrize (
@@ -580,9 +578,7 @@ def test_to_datetime_parse_timezone_keeps_name(self):
580
578
fmt = "%Y-%m-%d %H:%M:%S %z"
581
579
arg = Index (["2010-01-01 12:00:00 Z" ], name = "foo" )
582
580
result = to_datetime (arg , format = fmt )
583
- expected = DatetimeIndex (
584
- ["2010-01-01 12:00:00" ], tz = "UTC" , name = "foo"
585
- ) # .as_unit("ns")
581
+ expected = DatetimeIndex (["2010-01-01 12:00:00" ], tz = "UTC" , name = "foo" )
586
582
tm .assert_index_equal (result , expected )
587
583
588
584
@@ -615,9 +611,7 @@ def test_to_datetime_mixed_datetime_and_string(self):
615
611
d1 = datetime (2020 , 1 , 1 , 17 , tzinfo = timezone (- timedelta (hours = 1 )))
616
612
d2 = datetime (2020 , 1 , 1 , 18 , tzinfo = timezone (- timedelta (hours = 1 )))
617
613
res = to_datetime (["2020-01-01 17:00 -0100" , d2 ])
618
- expected = to_datetime ([d1 , d2 ]).tz_convert (
619
- timezone (timedelta (minutes = - 60 ))
620
- ) # .as_unit("ns")
614
+ expected = to_datetime ([d1 , d2 ]).tz_convert (timezone (timedelta (minutes = - 60 )))
621
615
tm .assert_index_equal (res , expected )
622
616
623
617
def test_to_datetime_mixed_string_and_numeric (self ):
@@ -641,7 +635,7 @@ def test_to_datetime_mixed_date_and_string(self, format):
641
635
# https://github.com/pandas-dev/pandas/issues/50108
642
636
d1 = date (2020 , 1 , 2 )
643
637
res = to_datetime (["2020-01-01" , d1 ], format = format )
644
- expected = DatetimeIndex (["2020-01-01" , "2020-01-02" ]) # .as_unit("ns")
638
+ expected = DatetimeIndex (["2020-01-01" , "2020-01-02" ])
645
639
tm .assert_index_equal (res , expected )
646
640
647
641
@pytest .mark .parametrize (
@@ -1140,7 +1134,7 @@ def test_to_datetime_dt64s(self, cache, dt):
1140
1134
def test_to_datetime_dt64s_and_str (self , arg , format ):
1141
1135
# https://github.com/pandas-dev/pandas/issues/50036
1142
1136
result = to_datetime ([arg , np .datetime64 ("2020-01-01" )], format = format )
1143
- expected = DatetimeIndex (["2001-01-01" , "2020-01-01" ]) # .as_unit("ns")
1137
+ expected = DatetimeIndex (["2001-01-01" , "2020-01-01" ])
1144
1138
tm .assert_index_equal (result , expected )
1145
1139
1146
1140
@pytest .mark .parametrize (
@@ -1734,11 +1728,11 @@ def test_iso_8601_strings_with_same_offset(self):
1734
1728
expected = Timestamp (ts_str )
1735
1729
assert result == expected
1736
1730
1737
- expected = DatetimeIndex ([Timestamp (ts_str )] * 2 ) # .as_unit("ns")
1731
+ expected = DatetimeIndex ([Timestamp (ts_str )] * 2 )
1738
1732
result = to_datetime ([ts_str ] * 2 )
1739
1733
tm .assert_index_equal (result , expected )
1740
1734
1741
- result = DatetimeIndex ([ts_str ] * 2 ) # .as_unit("ns")
1735
+ result = DatetimeIndex ([ts_str ] * 2 )
1742
1736
tm .assert_index_equal (result , expected )
1743
1737
1744
1738
def test_iso_8601_strings_with_different_offsets (self ):
@@ -3696,9 +3690,7 @@ def test_to_datetime_format_f_parse_nanos():
3696
3690
def test_to_datetime_mixed_iso8601 ():
3697
3691
# https://github.com/pandas-dev/pandas/issues/50411
3698
3692
result = to_datetime (["2020-01-01" , "2020-01-01 05:00:00" ], format = "ISO8601" )
3699
- expected = DatetimeIndex (
3700
- ["2020-01-01 00:00:00" , "2020-01-01 05:00:00" ]
3701
- ) # .as_unit("ns")
3693
+ expected = DatetimeIndex (["2020-01-01 00:00:00" , "2020-01-01 05:00:00" ])
3702
3694
tm .assert_index_equal (result , expected )
3703
3695
3704
3696
@@ -3767,13 +3759,12 @@ def test_to_datetime_with_empty_str_utc_false_format_mixed():
3767
3759
# GH 50887
3768
3760
vals = ["2020-01-01 00:00+00:00" , "" ]
3769
3761
result = to_datetime (vals , format = "mixed" )
3770
- expected = Index ([Timestamp ("2020-01-01 00:00+00:00" ), "NaT" ], dtype = "M8[ns , UTC]" )
3762
+ expected = Index ([Timestamp ("2020-01-01 00:00+00:00" ), "NaT" ], dtype = "M8[s , UTC]" )
3771
3763
tm .assert_index_equal (result , expected )
3772
3764
3773
3765
# Check that a couple of other similar paths work the same way
3774
- # FIXME: expect the same reso!
3775
3766
alt = to_datetime (vals )
3776
- tm .assert_index_equal (alt , expected . as_unit ( "s" ) )
3767
+ tm .assert_index_equal (alt , expected )
3777
3768
alt2 = DatetimeIndex (vals )
3778
3769
tm .assert_index_equal (alt2 , expected )
3779
3770
0 commit comments