Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge_asof doesn't allow float tolerance for float merges #22981

svenharris opened this issue Oct 3, 2018 · 2 comments


None yet
4 participants
Copy link

commented Oct 3, 2018

The merge_asof function allows you to merge on float values but doesn't allow tolerance value when performing this merge, unlike for integer and datetime merges. I'm currently working on a pull request to fix this by removing the error being thrown for non-integer numerical tolerances.

left = pd.DataFrame({'a': [1.1, 3.5, 10.9],
                     'left_val': ['a', 'b', 'c']})

right = pd.DataFrame({'a': [1.0, 2.5, 3.3, 7.5, 11.5],
                      'right_val': [1.0, 2.5, 3.3, 7.5, 11.5]})

expected = pd.DataFrame({'a': [1.1, 3.5, 10.9],
                         'left_val': ['a', 'b', 'c'],
                         'right_val': [1, 3.3, np.nan]})

result = pd.merge_asof(left, right, on='a', direction='nearest',

MergeError: key must be integer or timestamp

Expected output:

     a left_val  right_val
0   1.1        a        1.0
1   3.5        b        3.3
2  10.9        c        NaN

@svenharris svenharris referenced this issue Oct 3, 2018


Merge asof float fix #22982

0 of 4 tasks complete

@jreback jreback added this to the 0.24.0 milestone Oct 4, 2018


This comment has been minimized.

Copy link

commented Dec 22, 2018

this functionality will be officially added in the upcoming release 0.24?


This comment has been minimized.

Copy link
Contributor Author

commented Dec 22, 2018

You might find my answer to this stack overflow question helpful for the time being

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.