Skip to content

Commit

Permalink
add test and whatsnew
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemanley committed Oct 30, 2023
1 parent 0b040a1 commit 6dcefdc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v2.1.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ including other versions of pandas.

Fixed regressions
~~~~~~~~~~~~~~~~~
-
- Fixed regression in :meth:`DatetimeIndex.diff` raising ``TypeError`` (:issue:`55080`)
-

.. ---------------------------------------------------------------------------
Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/indexes/test_datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,11 @@ def test_where_cast_str(self, simple_index):

result = index.where(mask, ["foo"])
tm.assert_index_equal(result, expected)

@pytest.mark.parametrize("unit", ["ns", "us", "ms", "s"])
def test_diff(self, unit):
# GH 55080
dti = pd.to_datetime([10, 20, 30], unit=unit).as_unit(unit)
result = dti.diff(1)
expected = pd.TimedeltaIndex([pd.NaT, 10, 10], unit=unit).as_unit(unit)
tm.assert_index_equal(result, expected)

0 comments on commit 6dcefdc

Please sign in to comment.