I have two dataframes in python
1)salespersoncount
2)salesdata
I want to merge both tables on country and repeat salesdata no of time value of salesperson in salespersoncount and repeat this n times which will be an input and the final output should look like:
Can anyone please guide on above steps?
您可以像这样执行连接:
salespersoncount.join(salesdata.set_index('Country'), on='Country')
x=pd.merge(df1,df2,left_on='Country',right_on='Country',how='inner')
x=x.loc[x.index.repeat(x['SalesPers'])]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.