BYU Student Author: @Jae
Reviewers: @Nate, @klayton, @TylerBooth
Estimated Time to Solve: 20 minutes
We provide the solution to this challenge using:
- Python with Google Collab as the Integrated
- Go here to perform this challenge in Alteryx
- Go here to perform this challenge in Excel
Development Environment (IDE). The challenge requires the pandas library.
Need a program? Click here.
Overview
Little Chicken is a local fried chicken stand owned by your friend, Tom. Tom knows a lot about fried chicken, but not so much about business. In an attempt to boost his sales, Tom recently purchased a mini fridge. The refrigerator is consistently stocked with various beverages for his customers to take free of charge. Tom does not like to be controlling, so he allows his customers to take as many beverages as they need. Since purchasing the mini fridge, Tom has noticed a considerable increase in fried chicken sales but is concerned at how often he also restocks drinks.
Tom would like to evaluate the current state of his sales. He has been keeping an eye on how many drinks customers take each time they buy some chicken, recording the number of bottles alongside the quantity of chicken in their order. Tom is also interested in knowing whether his mini fridge decision has been more profitable for his stand. He has provided you with data on chicken order quantities before and after the purchase of the minifridge for comparison.
Tom purchases and sells his chicken for $0.99 and $3.99 per piece, respectively, and spends an average of $1.59 per bottle on drinks.
Instructions
Using the datafile linked below, compute the information Tom needs to evaluate the current state of his stand. Tom will need to know the following:
- Total Sales for both periods (Before/After the purchase of the mini fridge)
- Total Expenses for both periods, and
- Total Net Income (Profitability) for both periods
Do you think the mini fridge strategy is effective? What changes would you like Tom to make?
Data Files
Alternatively, this file can also be directly called by using the following code after importing pandas as pd:
df=pd.read_csv('https://byu.box.com/shared/static/rcuvuky4qmgs8lukrlia4w5kw8c4hm9w')
Suggestions and Hints
- Net Income = Sales - Expenses
- Since Tom didn’t own a mini fridge at the time of some chicken sales, you can assume that the drink expenses for this period were zero.
- separating the before/after sales column may help with calculating each total sales figure
Solution
Solution Code
import pandas as pd
# import data and create price/expense variables
df = pd.read_csv('https://byu.box.com/shared/static/rcuvuky4qmgs8lukrlia4w5kw8c4hm9w')
chicken_price = 3.99
chicken_exp = 0.99
drink_exp = 1.59
# Seperate the Before Period sales from the After Period
before_sales = df['Chicken Sold'][pd.isnull(df['Drinks Given'])].reset_index(drop=True)
after_sales = df['Chicken Sold'][pd.isnull(df['Drinks Given'])==False]
drinks_given = df['Drinks Given'][pd.isnull(df['Drinks Given'])==False]
# Add new columns to dataframe
df['before_sales'] = before_sales
df['after_sales'] = after_sales
df['drinks_given'] = drinks_given
# Remove original data columns
df = df.drop(columns=['Chicken Sold','Drinks Given']).dropna()
# Perform calculations
total_sales_before = sum(df['before_sales'])*chicken_price
total_expense_before = sum(df['before_sales'])*chicken_exp
net_income_before = total_sales_before - total_expense_before
total_sales_after = sum(df['after_sales'])*chicken_price
total_expense_after = (sum(df['after_sales'])*chicken_exp) + (sum(df['drinks_given'])*drink_exp)
net_income_after = total_sales_after - total_expense_after
# output information for Tom
print(f'Before\nTotal Sales: ${round(total_sales_before,2)}')
print(f'Total Expense: $({round(total_expense_before,2)})')
print(f'Net Income: ${round(net_income_before,2)}')
print(f'\nAfter\nTotal Sales: ${round(total_sales_after,2)}')
print(f'Total Expense: $({round(total_expense_after,2)})')
print(f'Net Income: ${round(net_income_after,2)}')
Solution Video: Challenge 2|PYTHON – Little Chicken