@@ -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 ):
@@ -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 (
@@ -1736,11 +1730,11 @@ def test_iso_8601_strings_with_same_offset(self):
1736
1730
expected = Timestamp (ts_str )
1737
1731
assert result == expected
1738
1732
1739
- expected = DatetimeIndex ([Timestamp (ts_str )] * 2 ) # .as_unit("ns")
1733
+ expected = DatetimeIndex ([Timestamp (ts_str )] * 2 )
1740
1734
result = to_datetime ([ts_str ] * 2 )
1741
1735
tm .assert_index_equal (result , expected )
1742
1736
1743
- result = DatetimeIndex ([ts_str ] * 2 ) # .as_unit("ns")
1737
+ result = DatetimeIndex ([ts_str ] * 2 )
1744
1738
tm .assert_index_equal (result , expected )
1745
1739
1746
1740
def test_iso_8601_strings_with_different_offsets (self ):
@@ -3703,9 +3697,7 @@ def test_to_datetime_format_f_parse_nanos():
3703
3697
def test_to_datetime_mixed_iso8601 ():
3704
3698
# https://github.com/pandas-dev/pandas/issues/50411
3705
3699
result = to_datetime (["2020-01-01" , "2020-01-01 05:00:00" ], format = "ISO8601" )
3706
- expected = DatetimeIndex (
3707
- ["2020-01-01 00:00:00" , "2020-01-01 05:00:00" ]
3708
- ) # .as_unit("ns")
3700
+ expected = DatetimeIndex (["2020-01-01 00:00:00" , "2020-01-01 05:00:00" ])
3709
3701
tm .assert_index_equal (result , expected )
3710
3702
3711
3703
@@ -3774,13 +3766,12 @@ def test_to_datetime_with_empty_str_utc_false_format_mixed():
3774
3766
# GH 50887
3775
3767
vals = ["2020-01-01 00:00+00:00" , "" ]
3776
3768
result = to_datetime (vals , format = "mixed" )
3777
- expected = Index ([Timestamp ("2020-01-01 00:00+00:00" ), "NaT" ], dtype = "M8[ns , UTC]" )
3769
+ expected = Index ([Timestamp ("2020-01-01 00:00+00:00" ), "NaT" ], dtype = "M8[s , UTC]" )
3778
3770
tm .assert_index_equal (result , expected )
3779
3771
3780
3772
# Check that a couple of other similar paths work the same way
3781
- # FIXME: expect the same reso!
3782
3773
alt = to_datetime (vals )
3783
- tm .assert_index_equal (alt , expected . as_unit ( "s" ) )
3774
+ tm .assert_index_equal (alt , expected )
3784
3775
alt2 = DatetimeIndex (vals )
3785
3776
tm .assert_index_equal (alt2 , expected )
3786
3777
0 commit comments