Skip to content
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...
merged_df = finance.merge(info,on='product_id')
merged_df = merged_df.merge(reviews,on='product_id')
merged_df = merged_df.merge(brands, on='product_id')
merged_df.dropna(inplace= True)
merged_df['price_label'] = pd.qcut(merged_df['listing_price'], q=4, labels=["Budget", "Average", "Expensive", "Elite"])
adidas_vs_nike = merged_df.groupby(['brand', 'price_label'], as_index=False).agg(num_products = ('price_label', 'count'), mean_revenue=('revenue', 'mean')).round(2)
print(adidas_vs_nike)
merged_df['description_length'] = merged_df['description'].str.len()
lenghtes = [0, 100, 200, 300, 400, 500, 600, 700]
labels = ["100", "200", "300", "400", "500", "600", "700"]
merged_df['description_length'] = pd.cut(merged_df['description_length'], bins = lenghtes, labels= labels)
description_lengths = merged_df.groupby("description_length", as_index=False).agg(
mean_rating=("rating", "mean"),
num_reviews=("reviews", "count")
).round(2)
print(description_lengths)
# List of footwear keywords
mylist = "shoe*|trainer*|foot*"
# Filter for footwear products
shoes = merged_df[merged_df["description"].str.contains(mylist)]
# Filter for clothing products
clothing = merged_df[~merged_df.isin(shoes["product_id"])]
# Remove null product_id values from clothing DataFrame
clothing.dropna(inplace=True)
# Create product_types DataFrame
product_types = pd.DataFrame({"num_clothing_products": len(clothing),
"median_clothing_revenue": clothing["revenue"].median(),
"num_footwear_products": len(shoes),
"median_footwear_revenue": shoes["revenue"].median()},
index=[0])
print(product_types)