Skip to content

Commit 0a0f582

Browse files
committed
API: Remove implicit matching of datetime.date with DatetimeIndex/Timestamp in indexing and merging tests
1 parent 6c8b76a commit 0a0f582

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

pandas/tests/frame/methods/test_asfreq.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,10 @@ def test_asfreq_with_date_object_index(self, frame_or_series):
192192
ts2 = ts.copy()
193193
ts2.index = [x.date() for x in ts2.index]
194194

195-
result = ts2.asfreq("4h", method="ffill")
196-
expected = ts.asfreq("4h", method="ffill")
197-
tm.assert_equal(result, expected)
195+
with pytest.raises(
196+
TypeError, match="Cannot compare Timestamp with datetime.date"
197+
):
198+
ts2.asfreq("4h", method="ffill")
198199

199200
def test_asfreq_with_unsorted_index(self, frame_or_series):
200201
# GH#39805

pandas/tests/indexes/datetimes/test_indexing.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -516,9 +516,10 @@ class TestGetIndexer:
516516
def test_get_indexer_date_objs(self):
517517
rng = date_range("1/1/2000", periods=20)
518518

519-
result = rng.get_indexer(rng.map(lambda x: x.date()))
520-
expected = rng.get_indexer(rng)
521-
tm.assert_numpy_array_equal(result, expected)
519+
with pytest.raises(
520+
TypeError, match="Cannot compare Timestamp with datetime.date"
521+
):
522+
rng.get_indexer(rng.map(lambda x: x.date()))
522523

523524
def test_get_indexer(self):
524525
idx = date_range("2000-01-01", periods=3)

pandas/tests/reshape/merge/test_merge.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,17 +2132,17 @@ def test_dtype_on_categorical_dates(self):
21322132

21332133
expected_outer = DataFrame(
21342134
[
2135-
[pd.Timestamp("2001-01-01").date(), 1.1, 1.3],
2136-
[pd.Timestamp("2001-01-02").date(), 1.3, np.nan],
2137-
[pd.Timestamp("2001-01-03").date(), np.nan, 1.4],
2135+
[pd.Timestamp("2001-01-01"), 1.1, 1.3],
2136+
[pd.Timestamp("2001-01-02"), 1.3, np.nan],
2137+
[pd.Timestamp("2001-01-03"), np.nan, 1.4],
21382138
],
21392139
columns=["date", "num2", "num4"],
21402140
)
21412141
result_outer = merge(df, df2, how="outer", on=["date"])
21422142
tm.assert_frame_equal(result_outer, expected_outer)
21432143

21442144
expected_inner = DataFrame(
2145-
[[pd.Timestamp("2001-01-01").date(), 1.1, 1.3]],
2145+
[[pd.Timestamp("2001-01-01"), 1.1, 1.3]],
21462146
columns=["date", "num2", "num4"],
21472147
)
21482148
result_inner = merge(df, df2, how="inner", on=["date"])

0 commit comments

Comments
 (0)