Skip to content

merge_asof() returns cryptic error with bad argument types #29130

Closed
@sdfordham

Description

@sdfordham

merge_asof arguments have to "...be a numeric column, such as datetimelike, integer, or float" but gives cryptic TypeError instead of ValueError on bad argument types?

import pandas as pd

left = pd.Series(['2019-06-01 00:09:12', '2019-06-01 00:10:29',
       '2019-06-01 00:20:30'], name='time')
right = pd.Series(['2019-06-01 00:01:12', '2019-06-01 00:01:12',
       '2019-06-01 00:01:12'], name='time')
pd.merge_asof(left, right)

Output:

...
TypeError: No matching signature found

versus e.g.

import pandas as pd

left = pd.Series(['2019-06-01 00:09:12', '2019-06-01 00:10:29',
       '2019-06-01 00:20:30'], name='time')
right = pd.Series(['2019-06-01 00:01:12', '2019-06-01 00:01:12',
       '2019-06-01 00:01:12'], name='time')

left = pd.to_datetime(left, infer_datetime_format=True)
right = pd.to_datetime(right, infer_datetime_format=True)

pd.merge_asof(left, right)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Error ReportingIncorrect or improved errors from pandasReshapingConcat, Merge/Join, Stack/Unstack, Explode

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions