Team, I am working on a logic...but taking more time than expected...
Problem:
-
Dataset (A) with 60 products ids
-
Dataset (B) has around 90K customers
I need to assign 30 random nomination ids for each customer.....Below is my code
#List of 90K customers
web_cust_temp = web_cust['prsn_code'].tolist()
default_nom_ids['key']=1
#Allocating n default to each customers
num_default=30
#Create empty dataframe
final_df=pd.DataFrame()
for x in web_cust_temp:
default_nom_temp=default_nom_ids.sample(n=num_default)
prsn_df=pd.DataFrame([x])
prsn_df['key']=1
interim=prsn_df.merge(default_nom_temp, how='inner', on=['key'])
final_df=pd.concat([final_df,interim],axis=0)
Aucun commentaire:
Enregistrer un commentaire