Skip to content
Optimizing 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 five datasets to investigate:
info.csvfinance.csvreviews.csvtraffic.csvbrands.csv
The company has asked you to answer the following questions:
What is the volume of products and average revenue for Adidas and Nike products based on price quartiles?
- Label products priced up to quartile one as
"Budget", quartile 2 as"Average", quartile 3 as"Expensive", and quartile 4 as"Elite". - Store as a
pandasDataFrame calledadidas_vs_nikecontaining the following columns:"brand","price_label","count", and"revenue".
Do any differences exist between the word count of a product's description and its mean rating?
- Store the results as a
pandasDataFrame calleddescription_lengthscontaining the following columns:"description_length","rating","reviews".
How does the volume of products and median revenue vary between clothing and footwear?
- Store as a
pandasDataFrame calledproduct_typescontaining the following columns:"clothing_products","clothing_revenue","footwear_products","footwear_revenue".
Completing the project
- Create a dictionary called
revenue_analysiscontaining the following key-value pairs:"brand_analysis":adidas_vs_nikeDataFrame."description_analysis":description_lengthsDataFrame."product_analysis":product_typesDataFrame
# Start coding here...
import pandas as pd
df_info1 = pd.read_csv("info.csv")
df_finance1 = pd.read_csv("finance.csv")
df_reviews1 = pd.read_csv("reviews.csv")
df_traffic1 = pd.read_csv("traffic.csv")
df_brands1 = pd.read_csv("brands.csv")
df_info = df_info1.dropna()
df_finance = df_finance1.dropna()
df_reviews = df_reviews1.dropna()
df_traffic = df_traffic1.dropna()
df_brands = df_brands1.dropna()Question Number 1
#merge all the data together
df_info.head()
merged_df = df_info.merge(df_finance, on = "product_id", how = "outer")
merged_df = merged_df.merge(df_reviews, on = "product_id", how = "outer")
merged_df = merged_df.merge(df_traffic, on = "product_id", how = "outer")
merged_df = merged_df.merge(df_brands, on = "product_id", how = "outer")
merged_df.dropna(inplace=True)
merged_df["listing_price"].describe()
# Check the data# create 4 bins based on quartile
bin_labels = ["Cheap","Average","Expensive", "Elite"]
merged_df["price_label"] = pd.qcut(merged_df['listing_price'], q=4, labels=bin_labels)
merged_df.head()#find revenue and product count based on brand and price label
adidas_vs_nike = merged_df.groupby(
["brand","price_label"]
).agg(
{
"price_label" : "count",
"revenue" : "mean"
}
)
print(adidas_vs_nike)Question Number Two
lengthes = [0,99,199,299,399,499,599,699]
labels = ["99","199","299","399","499","599","699"]
##labels should not include the zero#calculate string len of product description
merged_df ["word_limit"] = merged_df["description"].str.len()
# create bins based on word_limit
merged_df["word_limit"] = pd.cut(merged_df["word_limit"], bins=lengthes, labels=labels)
merged_df.head()
# show result for description_length and rating, and how many reviews
descriptions = merged_df.groupby(
"word_limit").agg(
{
"rating": "mean",
"reviews": "count"
}
)
print(description_lengths)Question Number 3
Compare footwear products and clothing products data
##create datasets copy
footwear = merged_df.copy(deep=True)
#create list for shoes, use wildcard
mylist = "shoe*|trainer*|foot*"
#create dataframe for footwear product
footwear = merged_df[merged_df["description"].str.contains(mylist)]
#filter for clothing products by using tilde ~, all data that are not in footwar
clothing = merged_df[~merged_df.isin(footwear["product_id"])]