Skip to content

Commit 19d0357

Browse files
committed
BUG: Remove special-casing for Python date objects in DatetimeIndex
1 parent 1c59ae7 commit 19d0357

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

pandas/tests/frame/indexing/test_indexing.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import re
88

99
import numpy as np
10+
import pyarrow as pa
1011
import pytest
1112

1213
from pandas._libs import iNaT
@@ -1887,6 +1888,10 @@ def test_datetime_indexer_consistency_pyarrow_date32():
18871888
ser3 = ser.astype("datetime64[ns]")
18881889
dti = Index(ser3)
18891890

1891+
# Make sure we don't treat Arrow date as timestamp
1892+
dtype = ser.dtype.arrow_dtype
1893+
assert not (dtype.kind == "M" and not pa.types.is_date(dtype))
1894+
18901895
with pytest.raises(KeyError):
18911896
dti.get_loc(ser[0])
18921897

pandas/tests/series/test_arithmetic.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,8 @@ def test_datetime_understood(self, unit):
758758
tm.assert_series_equal(result, expected)
759759

760760
def test_align_date_objects_with_datetimeindex(self):
761+
# GH#62158: v3.0.0 - DatetimeIndex no longer matches Python date labels.
762+
# The result is always all-NaN and the union index.
761763
rng = date_range("1/1/2000", periods=20)
762764
ts = Series(np.random.default_rng(2).standard_normal(20), index=rng)
763765

@@ -769,7 +771,7 @@ def test_align_date_objects_with_datetimeindex(self):
769771
result2 = ts2 + ts
770772

771773
date_labels = [x.date() for x in rng[5:]]
772-
expected_index = Index(date_labels + list(rng), dtype=object)
774+
expected_index = Index(list(rng) + date_labels, dtype=object)
773775

774776
# Length and index checks
775777
assert len(result) == 35

0 commit comments

Comments
 (0)