Skip to content

Commit c4fc925

Browse files
committed
BUG pandas-devGH-35558 merge_asof tolerance error
1 parent a9cb64a commit c4fc925

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

pandas/core/reshape/merge.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1667,7 +1667,7 @@ def _get_merge_keys(self):
16671667

16681668
msg = (
16691669
f"incompatible tolerance {self.tolerance}, must be compat "
1670-
f"with type {repr(lk.dtype)}"
1670+
f"with type {repr(lt.dtype)}"
16711671
)
16721672

16731673
if needs_i8_conversion(lt):

pandas/tests/reshape/merge/test_merge_asof.py

+15
Original file line numberDiff line numberDiff line change
@@ -1339,3 +1339,18 @@ def test_merge_index_column_tz(self):
13391339
index=pd.Index([0, 1, 2, 3, 4]),
13401340
)
13411341
tm.assert_frame_equal(result, expected)
1342+
1343+
def test_left_index_right_index_tolerance(self):
1344+
expected = self.asof.set_index("time")
1345+
trades = self.trades.set_index("time")
1346+
quotes = self.quotes.set_index("time")
1347+
1348+
result = merge_asof(
1349+
trades,
1350+
quotes,
1351+
left_index=True,
1352+
right_index=True,
1353+
by="ticker",
1354+
tolerance=Timedelta("1day"),
1355+
)
1356+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)