You are a product manager for a fitness studio based in Singapore and are interested in understanding the types of digital products you should offer. You already run successful local studios and have an established practice in Singapore. You want to understand the place of digital fitness products in your local market.
You would like to conduct a market analysis in Python to understand how to place your digital product in the regional market and what else is currently out there.
A market analysis will allow you to achieve several things. By identifying strengths of your competitors, you can gauge demand and create unique digital products and services. By identifying gaps in the market, you can find areas to offer a unique value proposition to potential users.
The sky is the limit for how you build on this beyond the project! Some areas to go investigate next are in-person classes, local gyms, local fitness classes, personal instructors, and even online personal instructors.
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style='white', palette='Pastel2')
import os
def read_file(filepath, plot = True):
"""
Read a CSV file from a given filepath, convert it into a pandas DataFrame,
and return a processed DataFrame with three columns: 'week', 'region', and 'interest'. Generate a line plot using Seaborn to visualize the data. This corresponds to the first graphic (time series) returned by trends.google.com.
"""
file = pd.read_csv(filepath, header=1)
df = file.set_index('Week').stack().reset_index()
df.columns = ['week','region','interest']
df['week'] = pd.to_datetime(df['week'])
plt.figure(figsize=(8,3))
df = df[df['interest']!="<1"]
df['interest'] = df['interest'].astype(float)
if plot:
sns.lineplot(data = df, x= 'week', y= 'interest',hue='region')
return df
def read_geo(filepath, multi=False):
"""
Read a CSV file from a given filepath, convert it into a pandas DataFrame,
and return a processed DataFrame with two columns: 'country' and 'interest'. Generate a bar plot using Seaborn to visualize the data. This corresponds to the second graphic returned by trends.google.com. Use multi=False if only one keyword is being analyzed, and multi=True if more than one keyword is being analyzed.
"""
file = pd.read_csv(filepath, header=1)
if not multi:
file.columns = ['country', 'interest']
plt.figure(figsize=(8,4))
sns.barplot(data = file.dropna().iloc[:25,:], y = 'country', x='interest')
if multi:
plt.figure(figsize=(3,8))
file = file.set_index('Country').stack().reset_index()
file.columns = ['country','category','interest']
file['interest'] = pd.to_numeric(file['interest'].apply(lambda x: x[:-1]))
sns.barplot(data=file.dropna(), y = 'country', x='interest', hue='category')
file = file.sort_values(ascending=False,by='interest')
return fileTask 1: Import Data uisng pre-defined functions
filepath = "data/workout.csv"
workout_df = read_file(filepath)Task 2: Access the highest interest by month
workout_by_month = workout_df[['week', 'interest']].set_index("week").resample("M").mean()
workout_by_month = workout_by_month.sort_values('interest', ascending=False)
month_high = workout_by_month.iloc[0:1, :]Task 3: Segment global interest by region i.e home workout, gym workout and home gym workout
filepath = "data/home_workout_gym_workout_home_gym.csv"
home_gym_df = read_file(filepath)
home_gym_2022_2023_df = home_gym_df[(home_gym_df['week'] >= '2022-01-01') & (home_gym_df['week'] <= '2023-12-31')]
home_gym_2022_2023_df = home_gym_2022_2023_df[['region', 'interest']].groupby('region').sum()
print('Interests from 2022 to 2023:\n', home_gym_2022_2023_df.sort_values('interest', ascending=False))
# As clearly seen frem the above print gym workout is the most popular workout in 2022 to 2023
current = 'gym workout'
covid_df = home_gym_df[(home_gym_df['week'] >= '2020-01-01') & (home_gym_df['week'] <= '2020-12-31')]
covid_df = covid_df[['region', 'interest']].groupby('region').sum()
print('\nInterests during Covid 2020:\n', covid_df.sort_values('interest', ascending=False))
# As clearly seen frem the above print home workout is the most popular workout during covid
peak_covid = 'home workout'Task 4: Assessing Regional Interest
filepath = "data/workout_global.csv"
workout_global_df = read_geo(filepath)
workout_global_df = workout_global_df.sort_values(ascending=False, by="interest")
top_25_countries = workout_global_df.iloc[:25, :]
top_25_countriesTask 5: Assessing regional demand for home workouts, gym workouts and home gyms
filepath = "data/geo_home_workout_gym_workout_home_gym.csv"
home_gym_global_df = read_geo(filepath, multi=True)
counties_of_interest = ["Philippines", "Singapore", "United Arab Emirates", "Qatar", "Kuwait", "Malaysia", "Sri Lanka", "India", "Pakistan"]
MESA = home_gym_global_df[home_gym_global_df['country'].isin(counties_of_interest)]
MESA
Task 6: Assess the split of interest by country and category
MESA = MESA.set_index(["country", 'category']).unstack()
top_home_country = 'Philippines'
MESATask 7: A deeper dive into two countries