A SaaS company seeks to uncover what drives its clients to renew subscriptions. They’ve collected data on client details, subscription records, and economic indicators and would like to connect them to better understand its clients’ behavior.
They’ve tasked you with analyzing these datasets to identify the key factors influencing clients’ decisions to renew their subscriptions.
Your analysis will provide them with insights into which customers are renewing their products and the reasons behind their renewals. The company can leverage these insights to make informed decisions to increase renewal rates and improve customer loyalty, helping them stay competitive and ensure long-term growth.
The Data
The company have provided you with three datasets for your analysis. A summary of each data is provided below.
client_details.csv
client_details.csv| Column | Description |
|---|---|
client_id | Unique identifier for each client. |
company_size | Size of the company (Small, Medium, Large). |
industry | Industry to which the client belongs (Fintech, Gaming, Crypto, AI, E-commerce). |
location | Location of the client (New York, New Jersey, Pennsylvania, Massachusetts, Connecticut). |
subscription_records.csv
subscription_records.csv| Column | Description |
|---|---|
client_id | Unique identifier for each client. |
subscription_type | Type of subscription (Yearly, Monthly). |
start_date | Start date of the subscription - YYYY-MM-DD. |
end_date | End date of the subscription - YYYY-MM-DD. |
renewed | Indicates whether the subscription was renewed (True, False). |
economic_indicators.csv
economic_indicators.csv| Column | Description |
|---|---|
start_date | Start date of the economic indicator (Quarterly) - YYYY-MM-DD. |
end_date | End date of the economic indicator (Quarterly) - YYYY-MM-DD. |
inflation_rate | Inflation rate in the period. |
gdp_growth_rate | Gross Domestic Product (GDP) growth rate in the period. |
# Import required libraries
import pandas as pd
# Import data
client_details = pd.read_csv('data/client_details.csv')
subscription_records = pd.read_csv('data/subscription_records.csv', parse_dates=['start_date', 'end_date'])
economic_indicators = pd.read_csv('data/economic_indicators.csv', parse_dates=['start_date', 'end_date'])
# Question 1
# client_details.head()
fintech_crypto_clients = client_details[client_details["industry"].isin(["Fintech", "Crypto"])]
df_fintech_crypto_clients = fintech_crypto_clients.groupby("industry").size().astype(int)
total_fintech_crypto_clients = df_fintech_crypto_clients.iloc[0] + df_fintech_crypto_clients[1]
print("total_fintech_crypto_clients:",total_fintech_crypto_clients)
# Question 2
client_subs = client_details.merge(subscription_records, on="client_id")
industry = client_subs[client_subs["renewed"] == True].groupby("industry").size().sort_values(ascending=False)
top_industry = industry.index[0]
print("\ntop_industry: ",top_industry)
# Question 3
subs_econo_inflation = pd.merge_asof(subscription_records.sort_values(by="end_date"), economic_indicators, left_on="end_date", right_on="start_date", direction="backward")
average_inflation_for_renewals = subs_econo_inflation[subs_econo_inflation["renewed"]==True]["inflation_rate"].mean()
print("\naverage_inflation_for_renewals:", average_inflation_for_renewals)
# Start coding here, good luck!
subscription_records.head()