diff --git a/pandas/tests/reshape/test_cut.py b/pandas/tests/reshape/test_cut.py index 3c612bdd1297c..0811c69859c0d 100644 --- a/pandas/tests/reshape/test_cut.py +++ b/pandas/tests/reshape/test_cut.py @@ -469,15 +469,22 @@ def test_datetime_cut(unit, box): # See https://github.com/pandas-dev/pandas/pull/56101#discussion_r1405325425 # for why we round to 8 seconds instead of 7 left = DatetimeIndex( - ["2012-12-31 23:57:08", "2013-01-01 16:00:00", "2013-01-02 08:00:00"] - ).as_unit(unit) + ["2012-12-31 23:57:08", "2013-01-01 16:00:00", "2013-01-02 08:00:00"], + dtype=f"M8[{unit}]", + ) else: left = DatetimeIndex( - ["2012-12-31 23:57:07.200000", "2013-01-01 16:00:00", "2013-01-02 08:00:00"] - ).as_unit(unit) + [ + "2012-12-31 23:57:07.200000", + "2013-01-01 16:00:00", + "2013-01-02 08:00:00", + ], + dtype=f"M8[{unit}]", + ) right = DatetimeIndex( - ["2013-01-01 16:00:00", "2013-01-02 08:00:00", "2013-01-03 00:00:00"] - ).as_unit(unit) + ["2013-01-01 16:00:00", "2013-01-02 08:00:00", "2013-01-03 00:00:00"], + dtype=f"M8[{unit}]", + ) exp_intervals = IntervalIndex.from_arrays(left, right) expected = Series(exp_intervals).astype(CategoricalDtype(ordered=True))