I have a dataset of transactions. What I'm doing is determining what customers have done just one purchase and what customer have purchased more than once.
what I did is:
df1['Counts'] = df1.groupby(['email_address']).transform('count') # get count of repeating emails/customers
result.ix[result.Counts >= 2,'Repeat'] = 1 # create new column with 1 for those that repeated and 0 for those who didn't
result.ix[result.Counts <= 1,'Repeat'] = 0
This gives me the overall count. However, the data frame has an additional column with the name of the website in which the purchase was made. What I want to do is to find customers that bought more than once in the same website.
Any idea how to change the previous function to get result as a column value breakdown?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire