Skip to content

ENH: vlookup or similar #54005

@Cokesalokes

Description

@Cokesalokes

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

I need to join 2 or more DFs (DF1 left, and DF2 right), but I only need to pull some of the information from DF2 whose column (let's say col_3) matches a column in DF1 (let's say col_B).

What we have now is to use a join or merge
DF_result= pd.merge(left=DF1, right=DF2, how='left', left_on='col_B', right_on='col_3')

But if there are more rows in DF2, that will make the number of rows in DF_result explode; whereas it should have the same number of rows as DF1.

This is the vlookup functionality from excel.

Feature Description

If I knew how to do this, I would.

Alternative Solutions

put everything into excel, and do a vlookup, but that only works if you have less than 200,000 rows, I am using CSVs with almost amillion....so excel keeps breaking.

Additional Context

Thanks for all your help, and sorry if this is already in the works. I know a lot of people have been looking for workarounds and such, but such a great feature for many.

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNeeds InfoClarification about behavior needed to assess issueReshapingConcat, Merge/Join, Stack/Unstack, Explode

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions