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 1500NaN1 AA 232 Y
2 Monitor 300NaN3 BB 2323 N
4 Printer 150NaN5 BB 2323 N
6 Desk 250NaN7 AA 2323 Y
8 Printer 23NaN9 DD 34 Y
10 Desk 45NaN11 BB 56 N
Post a Comment for "How Do I Perform A Vlookup Equivalent Operation On My Dataframe With Some Additional Conditions"