Skip to the content.

Home | Portfolio | GitHub | LinkedIn | Medium | Stack Overflow | Terms | E-mail

Visualising Customer Lifetime Value (LTV) Trends with Python Seaborn

When a business sells to customers, the reality is that a certain percentage of customers will cease buying from that business over a given period. This is what is known as churn.

The total revenue that a business can expect from a customer before they churn is known as customer lifetime value. Revenue remaining constant, the longer a customer keeps buying from a company - the higher their customer lifetime revenue (or LTV) will be.

LTV is a particularly important metric in industries such as telecommunications - which operates on the basis of a subscription model where the goal is to maximise ARPU (average revenue per user) while minimising churn (the percentage of customers that leave within a given period).


Let’s take the following example. Suppose that a hypothetical telecommunications company shows the following ARPU and postpaid churn rate statistics by quarter:

Year	Quarter	ARPU	Churn	LTV
1	Q1	36	0.69	5217.39
1	Q2	38	0.68	5588.24
1	Q3	33	0.75	4400
1	Q4	37	0.78	4743.59
2	Q1	34	0.69	4927.54
2	Q2	38	0.68	5588.24
2	Q3	34	0.76	4473.68
2	Q4	34	0.77	4415.58
3	Q1	38	0.68	5588.24
3	Q2	33	0.69	4782.61
3	Q3	34	0.76	4473.68
3	Q4	35	0.79	4430.38
4	Q1	32	0.7	4571.43
4	Q2	37	0.65	5692.31
4	Q3	34	0.79	4303.79
4	Q4	36	0.8	4500

LTV by quarter is calculated as:

(ARPU/Churn (%)) x 100

Now, let us visualise this using heatmaps and boxplots generated using Python’s Seaborn visualisation library.

LTV Visualisation: Heatmap

Looking at this heatmap, we can see that customer lifetime value is highest in Q1 and Q2 on the whole.

analysis = pd.pivot_table(df, index= 'quarter', columns='year', values="ltv")
sns.heatmap(analysis, annot=True, cmap="coolwarm", vmin=4300, vmax=5600, fmt='g')


Knowledge of these trends can be helpful, as it indicates when the company should take certain decisions to maximise LTV.

For instance, a lower LTV in Q3 and Q4 indicates that the company should possibly ramp up their marketing efforts to attract new customers during this time - as seasonal trends have shown a lower LTV among existing customers.

However, a higher LTV in Q1 and Q2 means that the company could afford to pull back on marketing efforts or coincide price increases across these quarters - as the rate of churn relative to ARPU has been shown to be lower during these seasons.

LTV Visualisation: Boxplot

In addition to using a heatmap to visualise seasonality of LTV - use of boxplots can be quite useful as well.

Consider that while there are quarters where LTV follows a similar pattern, there can also be quarters where we could see high dispersion across LTV from one year to the next.

To illustrate this, let us visualise LTV by quarter using a boxplot:

sns.boxplot(data=df, x="ltv", y="quarter")
plt.title("LTV by Quarter")"LTV by Quarter.png")


In the above example, we can see that the LTV spread across Q3 and Q4 is lower than that of Q1 and Q2. However, what is also interesting is that the spread across Q1 is also quite wide. While there are instances where LTV was quite high across Q1, there have also been instances where LTV was also significantly below average for that time of year.

In this regard, a company could look at this trend and decide to take actions such as postponing price increases until Q2, keep marketing efforts active in Q1, among others.


In this example, we have seen how to: