Skip to content Skip to sidebar Skip to footer

Pandas - Vlookup - Duplicate Values In Search Column

I am trying to mimic a v lookup (excel function) in Pandas ( using test data sets the merge function seems to work) - but I do have question regarding the example here https://pand

Solution 1:

Try this:

df.insert(2,'Column_That_I_Want_added', df['Cust_PO_Number'].map(df2.drop_duplicates('Cust_PO_Number').set_index('Cust_PO_Number')['Column_That_I_Want_added']))

where df is the original dataframe as well as the desired dataframe, and df2 is where you look up the data from.

Post a Comment for "Pandas - Vlookup - Duplicate Values In Search Column"