Skip to content
Project: Analyzing Online Sports Revenue
  • AI Chat
  • Code
  • Report
  • 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.csv
    • finance.csv
    • reviews.csv
    • traffic.csv
    • brands.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 pandas DataFrame called adidas_vs_nike containing the following columns: "brand", "price_label", "num_products", and "mean_revenue".

    Do any differences exist between the word count of a product's description and its mean rating?

    • Store the results as a pandas DataFrame called description_lengths containing the following columns: "description_length", "mean_rating", "num_reviews".

    How does the volume of products and median revenue vary between clothing and footwear?

    • Create a pandas DataFrame called product_types containing the following columns: "num_clothing_products", "median_clothing_revenue", "num_footwear_products", "median_footwear_revenue".
    # Start coding here... 
    import pandas as pd
    #Import Data
    df_info = pd.read_csv("info.csv")
    df_finance = pd.read_csv("finance.csv")
    df_reviews = pd.read_csv("reviews.csv")
    df_traffic = pd.read_csv("traffic.csv")
    df_brands = pd.read_csv("brands.csv")
    #Merge
    df_merge = df_info.merge(df_finance,on="product_id",how="outer")
    df_merge = df_merge.merge(df_reviews,on="product_id",how="outer")
    df_merge = df_merge.merge(df_traffic,on="product_id",how="outer")
    df_merge = df_merge.merge(df_brands,on="product_id",how="outer")
    #Drop NA
    df_merge = df_merge.dropna()
    
    #Quartile
    df_merge["price_label"] = pd.qcut(df_merge["listing_price"],q=4,labels=["Budget","Average","Expensive","Elite"])
    adidas_vs_nike = df_merge.groupby(["brand","price_label"],as_index=False).agg(
        num_products = ("product_id","count"),
        mean_revenue = ("revenue","mean")
    ).round(2)
    #Word Count
    df_merge["word_count"] = df_merge["description"].str.len()
    df_merge["description_length"] = pd.cut(df_merge["word_count"],bins=[0,100,200,300,400,500,600,700],labels=["100","200","300","400","500","600","700"])
    description_lengths = df_merge.groupby("description_length",as_index=False).agg(
        mean_rating = ("rating","mean"),
        num_reviews = ("reviews","count")
    ).round(2)
    #Product Type
    my_list = "shoe*|trainer*|foot*"
    df_cloth = df_merge[~df_merge["description"].str.contains(my_list)]
    df_foot = df_merge[df_merge["description"].str.contains(my_list)]
    
    num_clothing_products = df_cloth["product_id"].nunique()
    median_clothing_revenue = df_cloth["revenue"].median()
    num_footwear_products = df_foot["product_id"].nunique()
    median_footwear_revenue = df_foot["revenue"].median()
    
    product_types = pd.DataFrame(dict(num_clothing_products=[num_clothing_products],median_clothing_revenue=[median_clothing_revenue],num_footwear_products=[num_footwear_products],median_footwear_revenue=[median_footwear_revenue]))