admin管理员组文章数量:1393402
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
本文标签: pythonAssign unique codes for different User Id based on conditionsStack Overflow
版权声明:本文标题:python - Assign unique codes for different User Id based on conditions - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744645253a2617362.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论