Hi everyone I have a dataframe that looks like the following:
print(df):
TrxID Price Profit Online Satisfaction
### 10 10 Yes 25%
### 15 20 No 75%
### 18 -10 Yes 55%
### 10 30 No 70%
### 20 -50 Yes 79%
### 30 15 No 90%
### 30 15 No 15%
And I am hoping to create the following summary / cross tab / pivot table:
SatisfactionBins SalesMade AveSalePrice CountofOnline Profit Profit/SalesMade
20% 1 30 0 15 1500%
40% 1 10 1 10 1000%
60% 1 18 1 -10 -1000%
80% 3 15 1 0 0%
100% 1 30 0 15 1500%
Is this the right way to go about it?
df['Profit/SalesMade'] = df['Profit'] / df['SalesMade']
probbins = [0,0.2,0.4,0.6,0.8,1]
df['SatisfactionBins'] = pd.cut(dfclubhouse['Satisfaction'],bins=probbins)
df.groupby('SatisfactionBins')[(df['SalesMade'].count()),(df['Price'].mean()), etc etc]
I'm hoping someone might be able to help with 'best practice' in how to code this but im not sure where to go from here. Any help would be great! Thanks!