Performing A Merge Function In Python, When I Don't Want The Values To Repeat
HI This is a follow up from one of my previous questions how do I perform a vlookup equivalent operation on my dataframe with some additional conditions As in the other question, m
Solution 1:
Use:
df_m = pd.merge(df, df2, on="product", how="left")
m = df_m["product"].isin(df2["product"]) & df_m["product"].eq(df_m["product"].shift())
df_m = df_m[~m].reset_index(drop=True)
print(df_m)
This prints:
product number to_add
0 Computer 1500NaN1 AA 232 Y
2 Monitor 300NaN3 BB 2323 N
4 Printer1 150NaN5 BB 2323 N
6 Desk 250NaN7 AA 2323 Y
8 Printer2 23NaN9 DD 34 N
10 Desk 45NaN11 BB 56 N
Post a Comment for "Performing A Merge Function In Python, When I Don't Want The Values To Repeat"