Created
August 31, 2019 14:34
-
-
Save FBosler/0ded25f325bc384c173e91e699c164fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Aggregate the data a bit | |
orders_with_meals['Meal Price / Order Value'] = orders_with_meals['Meal Price']/orders_with_meals['Order Value'] | |
orders_with_meals['Meal Price / Order Value'] = pd.qcut( | |
orders_with_meals['Meal Price / Order Value']*-1, | |
5, | |
labels = ['Least Expensive','Less Expensive','Proportional','More Expensive','Most Expensive'][::-1] | |
) | |
orders_with_meals['Timing of Meal'] = pd.qcut( | |
orders_with_meals['Days of meal before order'], | |
3, | |
labels = ['After Order','Around Order','Before Order'] | |
) | |
data = orders_with_meals[orders_with_meals['Type of Meal'] != 'no meal'].groupby( | |
['Timing of Meal','Number Participants','Type of Meal','Meal Price / Order Value'] | |
).agg({'Converted': np.mean}).unstack().fillna(0).stack().reset_index() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment