Skip to content

Commit abcf477

Browse files
authored
TST: Added test for non-nano DTI intersection and updated whatsnew (#59280)
* TST: add intersection test non-nano * modify whatsnew
1 parent fe9ff74 commit abcf477

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

doc/source/whatsnew/v3.0.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ Datetimelike
507507
- Bug in :meth:`Dataframe.agg` with df with missing values resulting in IndexError (:issue:`58810`)
508508
- Bug in :meth:`DatetimeIndex.is_year_start` and :meth:`DatetimeIndex.is_quarter_start` does not raise on Custom business days frequencies bigger then "1C" (:issue:`58664`)
509509
- Bug in :meth:`DatetimeIndex.is_year_start` and :meth:`DatetimeIndex.is_quarter_start` returning ``False`` on double-digit frequencies (:issue:`58523`)
510-
- Bug in :meth:`DatetimeIndex.union` when ``unit`` was non-nanosecond (:issue:`59036`)
510+
- Bug in :meth:`DatetimeIndex.union` and :meth:`DatetimeIndex.intersection` when ``unit`` was non-nanosecond (:issue:`59036`)
511511
- Bug in :meth:`Series.dt.microsecond` producing incorrect results for pyarrow backed :class:`Series`. (:issue:`59154`)
512512
- Bug in :meth:`to_datetime` not respecting dayfirst if an uncommon date string was passed. (:issue:`58859`)
513513
- Bug in setting scalar values with mismatched resolution into arrays with non-nanosecond ``datetime64``, ``timedelta64`` or :class:`DatetimeTZDtype` incorrectly truncating those scalars (:issue:`56410`)

pandas/tests/indexes/datetimes/test_setops.py

+13
Original file line numberDiff line numberDiff line change
@@ -681,3 +681,16 @@ def test_union_non_nano_rangelike():
681681
freq="D",
682682
)
683683
tm.assert_index_equal(result, expected)
684+
685+
686+
def test_intersection_non_nano_rangelike():
687+
# GH 59271
688+
l1 = date_range("2024-01-01", "2024-01-03", unit="s")
689+
l2 = date_range("2024-01-02", "2024-01-04", unit="s")
690+
result = l1.intersection(l2)
691+
expected = DatetimeIndex(
692+
["2024-01-02", "2024-01-03"],
693+
dtype="datetime64[s]",
694+
freq="D",
695+
)
696+
tm.assert_index_equal(result, expected)

0 commit comments

Comments
 (0)