Skip to content Skip to sidebar Skip to footer

How Do I Perform A Vlookup Equivalent Operation On My Dataframe With Some Additional Conditions

HI I am trying to run lookup equivalent function on python but having tried merge and join I haven't hit the nail yet. so my first df is this list = ['Computer', 'AA', 'Monitor', '

Solution 1:

pd.merge indeed will do the job, probably you were not using it correctly:

pd.merge(df, df2, on="product", how="left")

will return:

     product  number to_add
0   Computer    1500    NaN
1         AA     232      Y
2    Monitor     300    NaN
3         BB    2323      N
4    Printer     150    NaN
5         BB    2323      N
6       Desk     250    NaN
7         AA    2323      Y
8    Printer      23    NaN
9         DD      34      Y
10      Desk      45    NaN
11        BB      56      N

Post a Comment for "How Do I Perform A Vlookup Equivalent Operation On My Dataframe With Some Additional Conditions"