All Data Labs

Customer analytics

RFM Customer Segmentation

medium3–4 hours4 datasets
Company
Wayfair
Job positions
Data AnalystBusiness AnalystData Scientist
Topics
RFM analysisCustomer segmentationpandasQuantile scoringCRM strategy

The scenario

Wayfair: Score every customer on recency, frequency and spend, build segments, and give the CRM team a plan for each one.

Wayfair's CRM team sends the same email to every customer, and results keep slipping. You're a customer analytics lead, and before the new year's campaign calendar is set, the team wants to group customers by how they actually buy so each group can get a different message.

Your task

Segment the store's customers using recency, frequency and monetary value (RFM) as of January 1, 2026, then describe each segment and recommend how the CRM team should treat it.

Instructions

  1. 1Load the files and clean them first: remove repeated orders and handle missing prices. Decide which orders count toward a customer's value and explain why.
  2. 2For every customer who has bought at least once, calculate recency (days since their last qualifying order as of January 1, 2026), frequency (number of qualifying orders) and monetary value (total spend).
  3. 3Score each measure, for example with quintiles, and explain how you handled ties and very large spenders.
  4. 4Combine the scores into 4 to 7 named segments with clear rules, such as champions, loyal customers, at risk and lost.
  5. 5For each segment, report the number of customers, share of revenue, average order value and typical time between orders.
  6. 6Check whether segments differ by acquisition channel or signup year, and whether segment sizes look sensible.
  7. 7Recommend one CRM action for each segment and the metric you would use to tell whether it worked.

Datasets

The data is synthetic and does not come from Wayfair, but it's modeled on how real companies record it, including the mess. All files come in one download.

orders.csv

One row per order placed between January 2024 and December 2025.

9,245 rows · 7 columns · 516 KB

ColumnTypeDescription
order_idintegerUnique ID of the order.
customer_idintegerThe customer who placed the order.
order_datedatetimeWhen the order was placed (UTC).
statustextFinal state of the order: completed, canceled or returned.
payment_methodtextHow the customer paid.
discount_codetextPromo code used on the order, if any.
shipping_feedecimalShipping charged to the customer, in USD.
Preview the first 5 rows
order_idcustomer_idorder_datestatuspayment_methoddiscount_codeshipping_fee
10000115302024-01-01 09:24:45completedcredit_cardempty6.95
10000235312024-01-01 10:37:49completedcredit_cardempty0
1000038402024-01-01 10:59:09completedcredit_cardempty0
1000047252024-01-01 12:48:34completedapple_payWELCOME100
10000534522024-01-01 17:44:03completedgift_cardempty0

order_items.csv

One row per product line in an order.

15,608 rows · 5 columns · 347 KB

ColumnTypeDescription
order_idintegerThe order this line belongs to.
product_idintegerThe product bought.
quantityintegerNumber of units bought.
unit_pricedecimalPrice of one unit at the time of the order, in USD, before discounts.
discount_amountdecimalTotal discount taken off this line, in USD.
Preview the first 5 rows
order_idproduct_idquantityunit_pricediscount_amount
1000011031138.990
1000021087145.990
10000210721141.990
10000310481139.990
1000041083119.992

products.csv

The store's product catalog.

90 rows · 5 columns · 4 KB

ColumnTypeDescription
product_idintegerUnique ID of the product.
product_nametextName shown on the website.
categorytextProduct category.
list_pricedecimalCurrent catalog price, in USD.
unit_costdecimalWhat one unit costs the store, in USD.
Preview the first 5 rows
product_idproduct_namecategorylist_priceunit_cost
1001Brass Chef KnifeKitchen61.9938.13
1002Walnut Cutting BoardKitchen138.9974.76
1003Matte Black Dutch Oven Kitchen22.9913.5
1004Classic SkilletKitchen75.9939.86
1005Linen Mixing Bowl SetKitchen 79.9941.11

customers.csv

One row per customer account.

3,600 rows · 4 columns · 108 KB

ColumnTypeDescription
customer_idintegerUnique ID of the customer.
signup_datedateDate the customer created an account.
statetextUS state from the customer's shipping address.
acquisition_channeltextHow the customer first found the store.
Preview the first 5 rows
customer_idsignup_datestateacquisition_channel
12024-09-13COorganic_search
22025-10-21ILpaid_search
32025-01-17AZreferral
42024-06-23FLpaid_social
52025-04-08ILpaid_social

Hint

Scoring with quintiles fails when many customers share the same value, which is common for frequency. Ranking first breaks the ties so every quintile holds the same number of customers.

rfm["f_score"] = pd.qcut(rfm["frequency"].rank(method="first"), 5, labels=[1, 2, 3, 4, 5])

Deliverable

A public GitHub repo with your analysis (a notebook or scripts), a CSV of customer IDs with their RFM scores and segment, and a README describing the segments and your recommendations.

When you're done, post your repo in the Solutions tab to share it with other learners.

What grading checks

Use this checklist to review your own work before you post and share it.

  • Submitted GitHub repo is public and reachable.
  • Repo contains at least one notebook or script file.
  • Repo contains a CSV with customer ID, recency, frequency, monetary and segment columns.
  • Recency, frequency and monetary value are calculated as of January 1, 2026 from cleaned, qualifying orders.
  • Segments have explicit rules and are described with size and revenue share.
  • Each segment has a specific CRM action and a way to measure it.