Skip to content
Project: Analyzing Online Sports Revenue
Sports clothing and athleisure attire is a huge industry, worth approximately $193 billion in 2021 with a strong growth forecast over the next decade!
In this notebook, you will undertake the role of a product analyst for an online sports clothing company. The company is specifically interested in how it can improve revenue. You will dive into product data such as pricing, reviews, descriptions, and ratings, as well as revenue and website traffic, to produce recommendations for its marketing and sales teams.
You've been provided with four datasets to investigate:
brands.csv
| Columns | Description |
|---|---|
product_id | Unique product identifier |
brand | Brand of the product |
finance.csv
| Columns | Description |
|---|---|
product_id | Unique product identifier |
listing_price | Original price of the product |
sale_price | Discounted price of the product |
discount | Discount off the listing price, as a decimal |
revenue | Revenue generated by the product |
info.csv
| Columns | Description |
|---|---|
product_name | Name of the product |
product_id | Unique product identifier |
description | Description of the product |
reviews.csv
| Columns | Description |
|---|---|
product_id | Unique product identifier |
rating | Average product rating |
reviews | Number of reviews for the product |
import pandas as pd
brands = pd.read_csv("brands.csv")
finance = pd.read_csv("finance.csv")
info = pd.read_csv("info.csv")
reviews = pd.read_csv("reviews.csv")
# Start coding here...
df = brands.merge(finance, on='product_id').merge(info, on='product_id').merge(reviews, on='product_id').dropna()
quartiles = df['listing_price'].quantile([0.25, 0.5, 0.75]).tolist()
# Define the labels for each quartile
labels = ['Budget', 'Average', 'Expensive', 'Elite']
# Function to assign quartile labels based on the product's value
def assign_quartile_label(value):
if value <= quartiles[0]:
return labels[0]
elif value <= quartiles[1]:
return labels[1]
elif value <= quartiles[2]:
return labels[2]
else:
return labels[3]
# Apply the function to create a new column with the quartile labels
df['price_label'] = df['listing_price'].apply(assign_quartile_label)
adidas_vs_nike = df.groupby(['brand', 'price_label']).agg({'product_id':'count', 'revenue':'mean'}).reset_index().rename(columns={'product_id':'num_products', 'revenue':'mean_revenue'})
adidas_vs_nike['mean_revenue'] = round(adidas_vs_nike['mean_revenue'], 2)adidas_vs_nike
limits=[0, 100, 200, 300, 400, 500, 600, 700]
bin_labels = ['100', '200', '300', '400', '500', '600', '700']
df['length'] = df['description'].str.len()
df['description_length'] = pd.cut(df['length'], bins=limits, labels=bin_labels)
description_lengths = df.groupby('description_length').agg({'rating':'mean', 'reviews':'count'}).reset_index().rename(columns={'rating':'mean_rating', 'reviews':'num_reviews'})
description_lengths['mean_rating'] = round(description_lengths['mean_rating'], 2)description_lengthsfootwear = df[df['description'].str.contains('shoe*|trainer*|foot*')]
clothing = df[~df['description'].isin(footwear['description'])]
values = [len(clothing['product_id']),
round(clothing['revenue'].median(), 2),
len(footwear['product_id']),
footwear['revenue'].median()]
cols = ["num_clothing_products", "median_clothing_revenue", "num_footwear_products", "median_footwear_revenue"]
product_types = pd.DataFrame([values], columns=cols)
product_types