Skip to content

You are a product manager for a fitness studio and are interested in understanding the current demand for digital fitness classes. You plan to conduct a market analysis in Python to gauge demand and identify potential areas for growth of digital products and services.

The Data

You are provided with a number of CSV files in the "Files/data" folder, which offer international and national-level data on Google Trends keyword searches related to fitness and related products.

workout.csv

ColumnDescription
'month'Month when the data was measured.
'workout_worldwide'Index representing the popularity of the keyword 'workout', on a scale of 0 to 100.

three_keywords.csv

ColumnDescription
'month'Month when the data was measured.
'home_workout_worldwide'Index representing the popularity of the keyword 'home workout', on a scale of 0 to 100.
'gym_workout_worldwide'Index representing the popularity of the keyword 'gym workout', on a scale of 0 to 100.
'home_gym_worldwide'Index representing the popularity of the keyword 'home gym', on a scale of 0 to 100.

workout_geo.csv

ColumnDescription
'country'Country where the data was measured.
'workout_2018_2023'Index representing the popularity of the keyword 'workout' during the 5 year period.

three_keywords_geo.csv

ColumnDescription
'country'Country where the data was measured.
'home_workout_2018_2023'Index representing the popularity of the keyword 'home workout' during the 5 year period.
'gym_workout_2018_2023'Index representing the popularity of the keyword 'gym workout' during the 5 year period.
'home_gym_2018_2023'Index representing the popularity of the keyword 'home gym' during the 5 year period.
# Import the necessary libraries
import pandas as pd
import matplotlib.pyplot as plt
import os
os.listdir()
df_three_kw_geo = pd.read_csv('./data/three_keywords_geo.csv')
print(df_three_kw_geo.head())
df_workout = pd.read_csv('./data/workout.csv')
print(df_workout.head())
df_workout_geo = pd.read_csv('./data/workout_geo.csv')
print(df_workout_geo.head())
#get the year in which the most searches occured
df_workout['year'] = df_workout['month'].apply(lambda x: x.split('-')[0])
df_search_by_year = df_workout.groupby('year').agg(total_searches=('workout_worldwide', "sum")).sort_values("total_searches",ascending=False).reset_index()
year_str = df_search_by_year.iloc[0]['year']
print(year_str)
df_workout_geo.fillna(0,inplace=True)
df_workout_geo.groupby("country")['workout_2018_2023'].sum()
top_country = df_workout_geo[df_workout_geo["country"].isin(["United States", "Japan", "Australia"])].iloc[0]['country']
print(top_country)
# Updated code
df_home_workout = df_three_kw_geo.groupby("Country")['home_workout_2018_2023'].sum().sort_values(ascending=False).reset_index()
df_home_workout_ph_ma = df_home_workout[df_home_workout["Country"].isin(["Philippines","Malaysia"])]
df_home_workout_ph_ma.head()
home_workout_geo = df_home_workout_ph_ma.iloc[0]['Country']
print(home_workout_geo)
df_three_kw = pd.read_csv('./data/three_keywords.csv')
df_three_kw['year'] = df_three_kw['month'].apply(lambda x: x.split('-')[0])
print(df_three_kw.head())
peak_covid_df = df_three_kw[df_three_kw['year']=='2020'].groupby('year').sum().reset_index()
peak_covid = (peak_covid_df.drop('year',axis=1).idxmax(axis=1).values[0])
print(peak_covid)
current_df = df_three_kw[df_three_kw['year']=='2023'].groupby('year').sum().reset_index()
current = (current_df.drop('year',axis=1).idxmax(axis=1).values[0])
print(current)