Project Python Foundations: FoodHub Data Analysis

Marks: 40

Context

The number of restaurants in New York is increasing day by day. Lots of students and busy professionals rely on those restaurants due to their hectic lifestyles. Online food delivery service is a great option for them. It provides them with good food from their favorite restaurants. A food aggregator company FoodHub offers access to multiple restaurants through a single smartphone app.

The app allows the restaurants to receive a direct online order from a customer. The app assigns a delivery person from the company to pick up the order after it is confirmed by the restaurant. The delivery person then uses the map to reach the restaurant and waits for the food package. Once the food package is handed over to the delivery person, he/she confirms the pick-up in the app and travels to the customer's location to deliver the food. The delivery person confirms the drop-off in the app after delivering the food package to the customer. The customer can rate the order in the app. The food aggregator earns money by collecting a fixed margin of the delivery order from the restaurants.

Objective

The food aggregator company has stored the data of the different orders made by the registered customers in their online portal. They want to analyze the data to get a fair idea about the demand of different restaurants which will help them in enhancing their customer experience. Suppose you are hired as a Data Scientist in this company and the Data Science team has shared some of the key questions that need to be answered. Perform the data analysis to find answers to these questions that will help the company to improve the business.

Data Description

The data contains the different data related to a food order. The detailed data dictionary is given below.

Data Dictionary

Let us start by importing the required libraries

Understanding the structure of the data

Observations:

The DataFrame has 9 columns as mentioned in the Data Dictionary. Data in each row corresponds to the order placed by a customer.

Question 1: Write the code to check the shape of the dataset and write your observations based on that. (0.5 mark)

Observations:

The dataset contains 1898 orders of food, and collects data on nine variables for each order. Those variables are: the order ID number, customer ID number, restaurant name, cuisine type, cost of the order, day of the week, rating, how long the food took to prepare, and the time it took to deliver the order.

Question 2: Write the observations based on the below output from the info() method. (0.5 mark)

Observations:

The data set contains three types of data: numerical data with decimals (float), whole number data (integer), and object data type, which includes both numerical and non-numerical categorical data.

Question 3: 'restaurant_name', 'cuisine_type', 'day_of_the_week' are object types. Write the code to convert the mentioned features to 'category' and write your observations on the same. (0.5 mark)

Observations:

Converting the restaurant name, cuisine type, and day of the week into the category data type aids the machine in applying data visualization models more appropriately in the future. By recognizing the restaurant name, cuisine type, and days of the week as categrories which often repeat, the data models in data visualization libraries can group data by category more easily than if it remained an object.

Question 4: Write the code to find the summary statistics and write your observations based on that. (1 mark)

Observations:

For the numerical data given:

Question 5: How many orders are not rated? (0.5 mark)

Observations:

736 orders, or 39% of values were not rated.

Exploratory Data Analysis (EDA)

Univariate Analysis

Question 6: Explore all the variables and provide observations on the distributions of all the relevant variables in the dataset. (5 marks)

Question 7: Write the code to find the top 5 restaurants that have received the highest number of orders. (1 mark)

Observations:

Shake Shack, the Meatball Shop, Blue Ribbon Sushi, Blue Ribbon Fried Chicken, and Parm are the top 5 restaurants with the greatest number of orders, and account for 33.4% of all orders.

Observations:

American cuisine is the most popular cuisine to order on weekends, with 415 orders.

Question 9: Write the code to find the number of total orders where the cost is above 20 dollars. What is the percentage of such orders in the dataset? (1 mark)

Observations:

555 orders, or 29.2% of all orders, cost more than $20.

Question 10: Write the code to find the mean delivery time based on this dataset. (1 mark)

Observations:

For all orders in the sample, the average delivery time is 24.16 minutes.

Question 11: Suppose the company has decided to give a free coupon of 15 dollars to the customer who has spent the maximum amount on a single order. Write the code to find the ID of the customer along with the order details. (1 mark)

Observations:

For the order that had the maximum cost on a single order, the Customer ID number is 62359. The customer ordered Mediterranean food from the restaurant Pylos during a weekday, which cost $35.41, took 21 minutes to prepare, took 29 minutes to deliver, and was given a 4-star rating.

Multivariate Analysis

Question 12: Perform bivariate/multivariate analysis to explore relationships between the important variables in the dataset. (7 marks)

Question 13: Suppose the company wants to provide a promotional offer in the advertisement of the restaurants. The condition to get the offer is that the restaurants must have a rating count of more than 50 and the average rating should be greater than 4. Write the code to find the restaurants fulfilling the criteria to get the promotional offer. (2 marks)

Observations:

The Blue Ribbon Fried Chicken, Blue Ribbon Sushi, Shake Shack, and the Meatball Shop all have a mean rating above 4.0 and over 50 reviews. Therefore, each of those restaurants should be advertised in the promotional offer.

Question 14: Suppose the company charges the restaurant 25% on the orders having cost greater than 20 dollars and 15% on the orders having cost greater than 5 dollars. Write the code to find the net revenue generated on all the orders given in the dataset. (2 marks)

Observations:

Total revenue for the sample of orders is $6166.30.

Question 15: Suppose the company wants to analyze the total time required to deliver the food. Write the code to find out the percentage of orders that have more than 60 minutes of total delivery time. (2 marks)

Note: The total delivery time is the summation of the food preparation time and delivery time.

Observations:

200 orders took over 60 minutes to deliver, or about 10.5% of total orders in this sample.

Question 16: Suppose the company wants to analyze the delivery time of the orders on weekdays and weekends. Write the code to find the mean delivery time on weekdays and weekends. Write your observations on the results. (2 marks)

Observations:

For deliveries placed on weekends, the average delivery time is 22.47 minutes. For deliveries placed on weekdays, the average delivery time is 28.34 minutes. Weekday deliveries could take longer for a number of reasons:

Conclusion and Recommendations

Question 17: Write the conclusions and business recommendations derived from the analysis. (3 marks)

Key Insights:

Restaurant Popularity: The top five restaurants with the most orders (Shake Shack, the Meatball Shop, Blue Ribbon Sushi, Blue Ribbon Fried Chicken, and Parm) account for 33.4% of all 1898 orders in the sample data. Offering promotional advertisments for these restaurants on the FoodHub app has the potential to drive demand for the restaurants and therefore revenue for FoodHub.

- Shake Shack has the highest number of 4 and 5 star ratings.
- The Meatball Shop also has over 50 5-star ratings.
- Blue Ribbon Sushi and Blue Ribbon Fried Chicken have a mix of 3, 4, and 5 star reviews, although total reviews are fewer than Shake Shack and the Meatball Shop.
- Parm has fewer total number of reviews than the other four Top 5 restaurants, and has a slightly greater number of 4 star than 5 star reviews.
- 736 orders, or 39% of all orders, were not rated.
- Only neutral (3 star) and positive (4 and 5 star) reviews are given. 50.6% of reviews given were 5-star reviews, 33.2% were 4-star reviews, and 16.1% were 3 star reviews. Customers with negative FoodHub experiences may not bother to rate the experience, or the values were left out.

In order to gain a better understanding of negative customer experiences, and to gain a holistic view of customer experiences with FoodHub for each restaurant, FoodHub should incentivize customers to leave honest reviews.

Cuisine Preferences: American, Japanese, and Italian food were most popular on both weekends and weekdays. To generate customer demand, FoodHub may want to offer promotions for customers who buy American, Japanese, and Italian food. FoodHub could also consider adding more American, Japanese, and Italian restaurants to their app.

Most cuisines tended to cost between 5 dollars and 35 dollars; however, Korean and Vietnamese food orders tended to be lower and less variable in price than other cuisines.

Order Costs: All orders cost between 4.47 dollars and 35.41 dollars. The average cost of an order is 16.50 dollars, but due to the right skew of the right-skewed distribution of costs, most orders cost more than the average.

Day of the Week: While the day of the week (weekday vs. weekend) doesn't seem to impact the cost of the order (both weekdays and weekends had a similar order cost distributions), or food preparation times, delivery times tend to be higher on weekdays (28 minutes on average) than on weekends (22 minutes on average). However, delivery times vary more during the weekend.

The average delivery time for all orders is 24 minutes, but due to the left skew of the data, most orders took more than 24 minutes to deliver.

In order to improve customer delivery times, FoodHub could recruit more delivery people during weekday rush hour, or optimize traffic routing on their app to avoid areas with heavy traffic on weekdays.

Preparation Time:

Preparation times vary greatly, with wost orders taking between 20-21 minutes, 25-26 minutes, 30-31 minutes, and 33-34 minutes to prepare. The average time to prepare and order is 27 minutes.

In order to shorten the times customers have to wait for food to be prepared, FoodHub could consider incentivizing restaurants that take a longer time to prepare food to prioritize FoodHub orders over other orders. They could achieve this through a promotional offering to the restaurants, or consider writing this condition of prioritization into existing contracts with the restaurants.