File tree 3 files changed +6
-10
lines changed
3 files changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -281,7 +281,7 @@ Reshaping
281
281
- Bug in :meth: `DataFrame.apply ` that caused incorrect output with empty :class: `DataFrame ` (:issue: `28202 `, :issue: `21959 `)
282
282
- Bug in :meth: `DataFrame.stack ` not handling non-unique indexes correctly when creating MultiIndex (:issue: `28301 `)
283
283
- :meth: `DataFrame.merge ` now preserves right frame's row order when executing a right merge (:issue: `27453 `)
284
- -
284
+ - Bug :func: ` merge_asof ` could not use :class: ` datetime.timedelta ` for `` tolerance `` kwarg ( :issue: ` 28098 `)
285
285
286
286
Sparse
287
287
^^^^^^
Original file line number Diff line number Diff line change 3
3
"""
4
4
5
5
import copy
6
+ import datetime
6
7
from functools import partial
7
8
import string
8
9
import warnings
@@ -1624,7 +1625,7 @@ def _get_merge_keys(self):
1624
1625
)
1625
1626
raise MergeError (msg )
1626
1627
1627
- # validate tolerance; must be a Timedelta if we have a DTI
1628
+ # validate tolerance; datetime.timedelta or Timedelta if we have a DTI
1628
1629
if self .tolerance is not None :
1629
1630
1630
1631
if self .left_index :
@@ -1640,7 +1641,7 @@ def _get_merge_keys(self):
1640
1641
)
1641
1642
1642
1643
if is_datetimelike (lt ):
1643
- if not isinstance (self .tolerance , Timedelta ):
1644
+ if not isinstance (self .tolerance , datetime . timedelta ):
1644
1645
raise MergeError (msg )
1645
1646
if self .tolerance < Timedelta (0 ):
1646
1647
raise MergeError ("tolerance must be positive" )
@@ -1710,6 +1711,7 @@ def flip(xs):
1710
1711
left_values = left_values .view ("i8" )
1711
1712
right_values = right_values .view ("i8" )
1712
1713
if tolerance is not None :
1714
+ tolerance = Timedelta (tolerance )
1713
1715
tolerance = tolerance .value
1714
1716
1715
1717
# a "by" parameter requires special handling
Original file line number Diff line number Diff line change @@ -592,13 +592,7 @@ def test_non_sorted(self):
592
592
593
593
@pytest .mark .parametrize (
594
594
"tolerance" ,
595
- [
596
- Timedelta ("1day" ),
597
- pytest .param (
598
- datetime .timedelta (days = 1 ),
599
- marks = pytest .mark .xfail (reason = "not implemented" , strict = True ),
600
- ),
601
- ],
595
+ [Timedelta ("1day" ), datetime .timedelta (days = 1 )],
602
596
ids = ["pd.Timedelta" , "datetime.timedelta" ],
603
597
)
604
598
def test_tolerance (self , tolerance ):
You can’t perform that action at this time.
0 commit comments