Skip to content

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

ColumnDescription
client_idUnique identifier for each client.
company_sizeSize of the company (Small, Medium, Large).
industryIndustry to which the client belongs (Fintech, Gaming, Crypto, AI, E-commerce).
locationLocation of the client (New York, New Jersey, Pennsylvania, Massachusetts, Connecticut).

subscription_records.csv

ColumnDescription
client_idUnique identifier for each client.
subscription_typeType of subscription (Yearly, Monthly).
start_dateStart date of the subscription - YYYY-MM-DD.
end_dateEnd date of the subscription - YYYY-MM-DD.
renewedIndicates whether the subscription was renewed (True, False).

economic_indicators.csv

ColumnDescription
start_dateStart date of the economic indicator (Quarterly) - YYYY-MM-DD.
end_dateEnd date of the economic indicator (Quarterly) - YYYY-MM-DD.
inflation_rateInflation rate in the period.
gdp_growth_rateGross 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()