From Data Drudgery
to Analytics Artistry

Stop rebuilding the same retail analyses from scratch. PyRetailScience gives your team pre-built, tested modules for segmentation, gain-loss, cross-shop, and more.

analysis.py
from pyretailscience.analysis.customer import TransactionChurn

# Analyze transaction churn
churn = TransactionChurn(df, churn_period=90)
churn.plot()

# Segment customers by value
from pyretailscience.segmentation.hml import HMLSegmentation
segments = HMLSegmentation(df)

Built with expertise doing analytics for scale-ups to multinationals

LoblawsIKIDominos PizzaMigrosSephoraSainsburysNectarMetroColesGANNIMindful ChefAuchan

Tailored for Retail, Powered by You

Leverage pre-built functions designed specifically for retail analytics. From customer segmentations to gain-loss analysis, PyRetailScience provides over a dozen building blocks to tackle retail-specific challenges.

See Analysis Modules →
Cross-shop Venn diagram

Trust Your Results, Every Time

Built with extensive unit testing and best practices, PyRetailScience ensures the accuracy and reliability of your analyses. Confidently present your findings, knowing they're backed by a robust, well-tested framework.

Get Started →
test_customer.py
import pytest
from pyretailscience.analysis.customer import TransactionChurn

def test_churn_has_expected_columns(sample_df):
    churn = TransactionChurn(sample_df, churn_period=90)
    assert "churned_pct" in churn.purchase_dist_df.columns
    assert churn.n_unique_customers == 1250

# 94% coverage across all modules

Consistent, Professional Charts in Seconds

Standardized visualizations that are presentation-ready with a few lines of code. Waterfall, Venn, heatmap, time series, and more.

Browse Plot Gallery →
Waterfall chart showing store cannibalization

Automate Repetitive Tasks, Focus on Insights

Loop analyses over different dimensions. Use the output of one analysis as input for another. Spend less time on data manipulation.

See Examples →
workflow.py
# Do our analysis
dbp = customer.DaysBetweenPurchases(df)
# Define the churn period as the 80th percentile
churn_period = dbp.purchases_percentile(0.8)
# Use that in our plot title
plot_title = f"Customers churn within {round(churn_period)} Days"
# Plot our chart
dbp.plot(title=plot_title)

Get started in seconds

Install PyRetailScience and run your first analysis in under a minute.

$ pip install pyretailscience
quickstart.py
from pyretailscience.analysis.customer import (
    PurchasesPerCustomer,
)

# Analyze purchase distribution
ppc = PurchasesPerCustomer(df)
ppc.plot()
# → A publication-ready chart, instantly.