Skip to content

ERR: left_index AND left_on or right_index AND right_on should raise #16228

Closed
@Satyadev592

Description

@Satyadev592

There seems to be a bug in the pandas merge , particularly on the left_index.

df1 = pd.DataFrame({'A': ['A0', 'A1', 'A2', 'A3'],
                'B': ['B0', 'B1', 'B2', 'B3'],
                'C': ['C0', 'C1', 'C2', 'C3'],
                'D': ['D0', 'D1', 'D2', 'D3']},index=[0, 1, 2, 3])

df2 = pd.DataFrame({'A': ['A0', 'A5', 'A6', 'A7'],
                'B': ['B1', 'B5', 'B6', 'B7'],
                'C': ['A1', 'C5', 'C6', 'C7'],
                'D': ['B1', 'D5', 'D6', 'D7']},index=[4, 5, 6, 7])

pd.merge(df1, df2, how='outer', left_index=True, left_on='A', right_on='A')
pd.merge(df1, df2, how='outer', right_index=True, left_on='A', right_on='A')

The above two merges give me different output.

This a fork of a stack overflow post-
http://stackoverflow.com/questions/43779003/will-output-change-if-right-index-is-used-instead-of-left-index-with-both-left-o

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