@@ -589,7 +589,7 @@ def test_comparison_tzawareness_compat(self, comparison_op, box_with_array):
589589 op = comparison_op
590590 box = box_with_array
591591
592- dr = date_range ("2016-01-01" , periods = 6 )
592+ dr = date_range ("2016-01-01" , periods = 6 , unit = "ns" )
593593 dz = dr .tz_localize ("US/Pacific" )
594594
595595 dr = tm .box_expected (dr , box )
@@ -637,7 +637,7 @@ def test_comparison_tzawareness_compat_scalars(self, comparison_op, box_with_arr
637637 # GH#18162
638638 op = comparison_op
639639
640- dr = date_range ("2016-01-01" , periods = 6 )
640+ dr = date_range ("2016-01-01" , periods = 6 , unit = "ns" )
641641 dz = dr .tz_localize ("US/Pacific" )
642642
643643 dr = tm .box_expected (dr , box_with_array )
@@ -676,7 +676,7 @@ def test_scalar_comparison_tzawareness(
676676 ):
677677 op = comparison_op
678678 tz = tz_aware_fixture
679- dti = date_range ("2016-01-01" , periods = 2 , tz = tz )
679+ dti = date_range ("2016-01-01" , periods = 2 , tz = tz , unit = "ns" )
680680
681681 dtarr = tm .box_expected (dti , box_with_array )
682682 xbox = get_upcast_box (dtarr , other , True )
@@ -833,8 +833,8 @@ def test_dt64arr_add_timedeltalike_scalar(
833833 # GH#22005, GH#22163 check DataFrame doesn't raise TypeError
834834 tz = tz_naive_fixture
835835
836- rng = date_range ("2000-01-01" , "2000-02-01" , tz = tz )
837- expected = date_range ("2000-01-01 02:00" , "2000-02-01 02:00" , tz = tz )
836+ rng = date_range ("2000-01-01" , "2000-02-01" , tz = tz , unit = "ns" )
837+ expected = date_range ("2000-01-01 02:00" , "2000-02-01 02:00" , tz = tz , unit = "ns" )
838838 if tz is not None :
839839 expected = expected ._with_freq (None )
840840
@@ -855,8 +855,8 @@ def test_dt64arr_sub_timedeltalike_scalar(
855855 ):
856856 tz = tz_naive_fixture
857857
858- rng = date_range ("2000-01-01" , "2000-02-01" , tz = tz )
859- expected = date_range ("1999-12-31 22:00" , "2000-01-31 22:00" , tz = tz )
858+ rng = date_range ("2000-01-01" , "2000-02-01" , tz = tz , unit = "ns" )
859+ expected = date_range ("1999-12-31 22:00" , "2000-01-31 22:00" , tz = tz , unit = "ns" )
860860 if tz is not None :
861861 expected = expected ._with_freq (None )
862862
@@ -870,7 +870,7 @@ def test_dt64arr_sub_timedeltalike_scalar(
870870 tm .assert_equal (rng , expected )
871871
872872 def test_dt64_array_sub_dt_with_different_timezone (self , box_with_array ):
873- t1 = date_range ("20130101" , periods = 3 ).tz_localize ("US/Eastern" )
873+ t1 = date_range ("20130101" , periods = 3 , unit = "ns" ).tz_localize ("US/Eastern" )
874874 t1 = tm .box_expected (t1 , box_with_array )
875875 t2 = Timestamp ("20130101" ).tz_localize ("CET" )
876876 tnaive = Timestamp (20130101 )
@@ -897,11 +897,11 @@ def test_dt64_array_sub_dt_with_different_timezone(self, box_with_array):
897897 tnaive - t1
898898
899899 def test_dt64_array_sub_dt64_array_with_different_timezone (self , box_with_array ):
900- t1 = date_range ("20130101" , periods = 3 ).tz_localize ("US/Eastern" )
900+ t1 = date_range ("20130101" , periods = 3 , unit = "ns" ).tz_localize ("US/Eastern" )
901901 t1 = tm .box_expected (t1 , box_with_array )
902- t2 = date_range ("20130101" , periods = 3 ).tz_localize ("CET" )
902+ t2 = date_range ("20130101" , periods = 3 , unit = "ns" ).tz_localize ("CET" )
903903 t2 = tm .box_expected (t2 , box_with_array )
904- tnaive = date_range ("20130101" , periods = 3 )
904+ tnaive = date_range ("20130101" , periods = 3 , unit = "ns" )
905905
906906 result = t1 - t2
907907 expected = TimedeltaIndex (
@@ -928,7 +928,7 @@ def test_dt64arr_add_sub_td64_nat(self, box_with_array, tz_naive_fixture):
928928 # GH#23320 special handling for timedelta64("NaT")
929929 tz = tz_naive_fixture
930930
931- dti = date_range ("1994-04-01" , periods = 9 , tz = tz , freq = "QS" )
931+ dti = date_range ("1994-04-01" , periods = 9 , tz = tz , freq = "QS" , unit = "ns" )
932932 other = np .timedelta64 ("NaT" )
933933 expected = DatetimeIndex (["NaT" ] * 9 , tz = tz ).as_unit ("ns" )
934934
@@ -947,11 +947,11 @@ def test_dt64arr_add_sub_td64_nat(self, box_with_array, tz_naive_fixture):
947947
948948 def test_dt64arr_add_sub_td64ndarray (self , tz_naive_fixture , box_with_array ):
949949 tz = tz_naive_fixture
950- dti = date_range ("2016-01-01" , periods = 3 , tz = tz )
950+ dti = date_range ("2016-01-01" , periods = 3 , tz = tz , unit = "ns" )
951951 tdi = TimedeltaIndex (["-1 Day" , "-1 Day" , "-1 Day" ])
952952 tdarr = tdi .values
953953
954- expected = date_range ("2015-12-31" , "2016-01-02" , periods = 3 , tz = tz )
954+ expected = date_range ("2015-12-31" , "2016-01-02" , periods = 3 , tz = tz , unit = "ns" )
955955
956956 dtarr = tm .box_expected (dti , box_with_array )
957957 expected = tm .box_expected (expected , box_with_array )
@@ -961,7 +961,7 @@ def test_dt64arr_add_sub_td64ndarray(self, tz_naive_fixture, box_with_array):
961961 result = tdarr + dtarr
962962 tm .assert_equal (result , expected )
963963
964- expected = date_range ("2016-01-02" , "2016-01-04" , periods = 3 , tz = tz )
964+ expected = date_range ("2016-01-02" , "2016-01-04" , periods = 3 , tz = tz , unit = "ns" )
965965 expected = tm .box_expected (expected , box_with_array )
966966
967967 result = dtarr - tdarr
@@ -991,7 +991,7 @@ def test_dt64arr_add_sub_td64ndarray(self, tz_naive_fixture, box_with_array):
991991 )
992992 def test_dt64arr_sub_dtscalar (self , box_with_array , ts ):
993993 # GH#8554, GH#22163 DataFrame op should _not_ return dt64 dtype
994- idx = date_range ("2013-01-01" , periods = 3 )._with_freq (None )
994+ idx = date_range ("2013-01-01" , periods = 3 , unit = "ns" )._with_freq (None )
995995 idx = tm .box_expected (idx , box_with_array )
996996
997997 expected = TimedeltaIndex (["0 Days" , "1 Day" , "2 Days" ])
@@ -1005,7 +1005,7 @@ def test_dt64arr_sub_dtscalar(self, box_with_array, ts):
10051005 tm .assert_equal (result , - expected )
10061006
10071007 def test_dt64arr_sub_timestamp_tzaware (self , box_with_array ):
1008- ser = date_range ("2014-03-17" , periods = 2 , freq = "D" , tz = "US/Eastern" )
1008+ ser = date_range ("2014-03-17" , periods = 2 , freq = "D" , tz = "US/Eastern" , unit = "ns" )
10091009 ser = ser ._with_freq (None )
10101010 ts = ser [0 ]
10111011
@@ -1312,11 +1312,11 @@ def test_dti_add_tick_tzaware(self, tz_aware_fixture, box_with_array):
13121312 # GH#21610, GH#22163 ensure DataFrame doesn't return object-dtype
13131313 tz = tz_aware_fixture
13141314 if tz == "US/Pacific" :
1315- dates = date_range ("2012-11-01" , periods = 3 , tz = tz )
1315+ dates = date_range ("2012-11-01" , periods = 3 , tz = tz , unit = "ns" )
13161316 offset = dates + pd .offsets .Hour (5 )
13171317 assert dates [0 ] + pd .offsets .Hour (5 ) == offset [0 ]
13181318
1319- dates = date_range ("2010-11-01 00:00" , periods = 3 , tz = tz , freq = "h" )
1319+ dates = date_range ("2010-11-01 00:00" , periods = 3 , tz = tz , freq = "h" , unit = "ns" )
13201320 expected = DatetimeIndex (
13211321 ["2010-11-01 05:00" , "2010-11-01 06:00" , "2010-11-01 07:00" ],
13221322 freq = "h" ,
@@ -1604,7 +1604,9 @@ def test_dti_add_sub_nonzero_mth_offset(
16041604 ):
16051605 # GH 26258
16061606 tz = tz_aware_fixture
1607- date = date_range (start = "01 Jan 2014" , end = "01 Jan 2017" , freq = "YS" , tz = tz )
1607+ date = date_range (
1608+ start = "01 Jan 2014" , end = "01 Jan 2017" , freq = "YS" , tz = tz , unit = "ns"
1609+ )
16081610 date = tm .box_expected (date , box_with_array , False )
16091611 mth = getattr (date , op )
16101612 result = mth (offset )
@@ -1667,7 +1669,7 @@ def test_dt64_series_arith_overflow(self):
16671669 # GH#12534, fixed by GH#19024
16681670 dt = Timestamp ("1700-01-31" )
16691671 td = Timedelta ("20000 Days" )
1670- dti = date_range ("1949-09-30" , freq = "100YE" , periods = 4 )
1672+ dti = date_range ("1949-09-30" , freq = "100YE" , periods = 4 , unit = "ns" )
16711673 ser = Series (dti )
16721674 msg = "Overflow in int64 addition"
16731675 with pytest .raises (OverflowError , match = msg ):
@@ -1890,7 +1892,7 @@ def test_sub_single_tz(self, unit):
18901892 def test_dt64tz_series_sub_dtitz (self ):
18911893 # GH#19071 subtracting tzaware DatetimeIndex from tzaware Series
18921894 # (with same tz) raises, fixed by #19024
1893- dti = date_range ("1999-09-30" , periods = 10 , tz = "US/Pacific" )
1895+ dti = date_range ("1999-09-30" , periods = 10 , tz = "US/Pacific" , unit = "ns" )
18941896 ser = Series (dti )
18951897 expected = Series (TimedeltaIndex (["0days" ] * 10 ))
18961898
@@ -2040,7 +2042,7 @@ def test_dti_add_tdi(self, tz_naive_fixture):
20402042 tz = tz_naive_fixture
20412043 dti = DatetimeIndex ([Timestamp ("2017-01-01" , tz = tz )] * 10 )
20422044 tdi = pd .timedelta_range ("0 days" , periods = 10 )
2043- expected = date_range ("2017-01-01" , periods = 10 , tz = tz )
2045+ expected = date_range ("2017-01-01" , periods = 10 , tz = tz , unit = "ns" )
20442046 expected = expected ._with_freq (None )
20452047
20462048 # add with TimedeltaIndex
@@ -2062,7 +2064,7 @@ def test_dti_iadd_tdi(self, tz_naive_fixture):
20622064 tz = tz_naive_fixture
20632065 dti = DatetimeIndex ([Timestamp ("2017-01-01" , tz = tz )] * 10 )
20642066 tdi = pd .timedelta_range ("0 days" , periods = 10 )
2065- expected = date_range ("2017-01-01" , periods = 10 , tz = tz )
2067+ expected = date_range ("2017-01-01" , periods = 10 , tz = tz , unit = "ns" )
20662068 expected = expected ._with_freq (None )
20672069
20682070 # iadd with TimedeltaIndex
@@ -2088,7 +2090,7 @@ def test_dti_sub_tdi(self, tz_naive_fixture):
20882090 tz = tz_naive_fixture
20892091 dti = DatetimeIndex ([Timestamp ("2017-01-01" , tz = tz )] * 10 )
20902092 tdi = pd .timedelta_range ("0 days" , periods = 10 )
2091- expected = date_range ("2017-01-01" , periods = 10 , tz = tz , freq = "-1D" )
2093+ expected = date_range ("2017-01-01" , periods = 10 , tz = tz , freq = "-1D" , unit = "ns" )
20922094 expected = expected ._with_freq (None )
20932095
20942096 # sub with TimedeltaIndex
0 commit comments