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

pd.merge_asof() matches out of tolerance when allow_exact_matches=False #13695

chrisaycock opened this Issue Jul 18, 2016 · 1 comment


None yet
2 participants

chrisaycock commented Jul 18, 2016

Using these DataFrames for this example:

df1 = pd.DataFrame({'time':pd.to_datetime(['2016-07-15 13:30:00.030']), 'username':['bob']})
df2 = pd.DataFrame({'time':pd.to_datetime(['2016-07-15 13:30:00.000', '2016-07-15 13:30:00.030']), 'version':[1, 2]})

I can perform the pd.merge_asof() as expected:

In [153]: df1
                     time username
0 2016-07-15 13:30:00.030      bob

In [154]: df2
                     time  version
0 2016-07-15 13:30:00.000        1
1 2016-07-15 13:30:00.030        2

In [155]: pd.merge_asof(df1, df2, on='time')
                     time username  version
0 2016-07-15 13:30:00.030      bob        2

If I disable the exact matches, then I get the prior entry as expected:

In [156]: pd.merge_asof(df1, df2, on='time', allow_exact_matches=False)
                     time username  version
0 2016-07-15 13:30:00.030      bob        1

But the tolerance isn't respected when I disable the exact matches!

In [157]: pd.merge_asof(df1, df2, on='time', allow_exact_matches=False, tolerance=pd.Timedelta('10ms'))
                     time username  version
0 2016-07-15 13:30:00.030      bob        1

I expect to get a null here.

This is pandas version 0.18.0+408.gd8f3d73.


This comment has been minimized.

Show comment
Hide comment

jreback Jul 18, 2016


hmm, that does look buggy


jreback commented Jul 18, 2016

hmm, that does look buggy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment