Project: Analyzing Online Sports Revenue
  • AI Chat
  • Code
  • Report
  • Beta
    Spinner

    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

    ColumnsDescription
    product_idUnique product identifier
    brandBrand of the product

    finance.csv

    ColumnsDescription
    product_idUnique product identifier
    listing_priceOriginal price of the product
    sale_priceDiscounted price of the product
    discountDiscount off the listing price, as a decimal
    revenueRevenue generated by the product

    info.csv

    ColumnsDescription
    product_nameName of the product
    product_idUnique product identifier
    descriptionDescription of the product

    reviews.csv

    ColumnsDescription
    product_idUnique product identifier
    ratingAverage product rating
    reviewsNumber of reviews for the product
    import pandas as pd
    
    #Reading the .csv files
    brands = pd.read_csv("brands.csv") 
    finance = pd.read_csv("finance.csv")
    info = pd.read_csv("info.csv")
    reviews = pd.read_csv("reviews.csv")
    full_data = brands.merge(finance,on='product_id')\
                        .merge(info,on='product_id')\
                        .merge(reviews,on='product_id')
    full_data.dropna(inplace=True)
    full_data.info()
    full_data['price_label'] = pd.qcut(full_data['listing_price'],q=4,labels=['Budget','Average','Expensive','Elite'])
    full_data.head()
    #Grouping, aggregating, renaming and rounding numbers
    adidas_vs_nike = full_data.groupby(by=['brand','price_label'], as_index=False) \
                              .agg(
                                num_products = ('product_id', 'count'),
                                mean_revenue = ('revenue', 'mean')) \
                              .round(2)
    adidas_vs_nike.head()
    #Creating Description Lengths based on bins of 100 words
    full_data['description_length'] = full_data['description'].str.len()
    max_range = round(full_data['description_length'].max()/100)*100
    limits = list(range(0,max_range+100,100))
    news_labels = [str(item) for item in limits[1:]]
    
    full_data['description_length'] = pd.cut(full_data['description_length'],limits,labels=news_labels)
    #Grouping, aggregating, renaming and rounding numbers
    description_lengths = full_data.groupby(by='description_length', as_index=False) \
                                   .agg(
                                        mean_rating = ('rating','mean'),
                                        num_reviews = ('reviews','count')) \
                                   .round(2)
    
    description_lengths.head()
    full_data['product_type'] = full_data['description'].str.contains("shoe*|trainer*|foot*").map({True:'footwear',False:'clothing'})
    int_table = pd.pivot_table(data=full_data,values=['product_id','revenue'],columns='product_type',aggfunc={'product_id':'count','revenue':'median'}).unstack()
    product_types_dict = {
        'num_clothing_products': [int_table[('clothing','product_id')]],
        'median_clothing_revenue': [int_table[('clothing','revenue')]],
        'num_footwear_products' : [int_table[('footwear','product_id')]],
        'median_footwear_revenue': [int_table[('footwear','revenue')]]
    }
    product_types = pd.DataFrame(product_types_dict)
    product_types.head()