I have to assign a unique code from vouchers to every user id, with the condition of trips have to be the same. For example, if a user made 3 trips, it will be assigned a voucher of trips == 3. The column used is binary.
- winners: columns user id, trips
- vouchers: columns code, used, trips
I tried this:
vouchers_disponibles = vouchers[vouchers["used"].isna()].copy()
test = ganadores.head(1000)
df_test = test.merge(vouchers_disponibles, left_on='DO sin dcto', right_on='viajes', how='left') df_test.drop_duplicates(subset=['User Id'])
But this will duplicate values from the user id for every code