Skip to content

ERR: better error message on merging for incompat types #18068

Closed
@jreback

Description

@jreback

would be nice to have the types outputted in the error message

In [23]:         left = pd.DataFrame({'a': [1, 5, 10],
    ...:                              'left_val': ['a', 'b', 'c']})
    ...:         right = pd.DataFrame({'a': [1, 2, 3, 6, 7],
    ...:                               'right_val': [1, 2, 3, 6, 7]})
    ...: 
    ...: 

In [24]: pd.merge_asof(left, right, on='a')
Out[24]: 
    a left_val  right_val
0   1        a          1
1   5        b          3
2  10        c          7

In [25]: pd.merge_asof(left, right.assign(a=right.a.astype('i4')), on='a')
MergeError: incompatible merge keys, must be the same type

Metadata

Metadata

Assignees

No one assigned

    Labels

    Error ReportingIncorrect or improved errors from pandas

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions