Customer analytics
RFM Customer Segmentation
- 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
- 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.
- 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).
- 3Score each measure, for example with quintiles, and explain how you handled ties and very large spenders.
- 4Combine the scores into 4 to 7 named segments with clear rules, such as champions, loyal customers, at risk and lost.
- 5For each segment, report the number of customers, share of revenue, average order value and typical time between orders.
- 6Check whether segments differ by acquisition channel or signup year, and whether segment sizes look sensible.
- 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
| Column | Type | Description |
|---|---|---|
| order_id | integer | Unique ID of the order. |
| customer_id | integer | The customer who placed the order. |
| order_date | datetime | When the order was placed (UTC). |
| status | text | Final state of the order: completed, canceled or returned. |
| payment_method | text | How the customer paid. |
| discount_code | text | Promo code used on the order, if any. |
| shipping_fee | decimal | Shipping charged to the customer, in USD. |
Preview the first 5 rowsHide preview
| order_id | customer_id | order_date | status | payment_method | discount_code | shipping_fee |
|---|---|---|---|---|---|---|
| 100001 | 1530 | 2024-01-01 09:24:45 | completed | credit_card | empty | 6.95 |
| 100002 | 3531 | 2024-01-01 10:37:49 | completed | credit_card | empty | 0 |
| 100003 | 840 | 2024-01-01 10:59:09 | completed | credit_card | empty | 0 |
| 100004 | 725 | 2024-01-01 12:48:34 | completed | apple_pay | WELCOME10 | 0 |
| 100005 | 3452 | 2024-01-01 17:44:03 | completed | gift_card | empty | 0 |
order_items.csv
One row per product line in an order.
15,608 rows · 5 columns · 347 KB
| Column | Type | Description |
|---|---|---|
| order_id | integer | The order this line belongs to. |
| product_id | integer | The product bought. |
| quantity | integer | Number of units bought. |
| unit_price | decimal | Price of one unit at the time of the order, in USD, before discounts. |
| discount_amount | decimal | Total discount taken off this line, in USD. |
Preview the first 5 rowsHide preview
| order_id | product_id | quantity | unit_price | discount_amount |
|---|---|---|---|---|
| 100001 | 1031 | 1 | 38.99 | 0 |
| 100002 | 1087 | 1 | 45.99 | 0 |
| 100002 | 1072 | 1 | 141.99 | 0 |
| 100003 | 1048 | 1 | 139.99 | 0 |
| 100004 | 1083 | 1 | 19.99 | 2 |
products.csv
The store's product catalog.
90 rows · 5 columns · 4 KB
| Column | Type | Description |
|---|---|---|
| product_id | integer | Unique ID of the product. |
| product_name | text | Name shown on the website. |
| category | text | Product category. |
| list_price | decimal | Current catalog price, in USD. |
| unit_cost | decimal | What one unit costs the store, in USD. |
Preview the first 5 rowsHide preview
| product_id | product_name | category | list_price | unit_cost |
|---|---|---|---|---|
| 1001 | Brass Chef Knife | Kitchen | 61.99 | 38.13 |
| 1002 | Walnut Cutting Board | Kitchen | 138.99 | 74.76 |
| 1003 | Matte Black Dutch Oven | Kitchen | 22.99 | 13.5 |
| 1004 | Classic Skillet | Kitchen | 75.99 | 39.86 |
| 1005 | Linen Mixing Bowl Set | Kitchen | 79.99 | 41.11 |
customers.csv
One row per customer account.
3,600 rows · 4 columns · 108 KB
| Column | Type | Description |
|---|---|---|
| customer_id | integer | Unique ID of the customer. |
| signup_date | date | Date the customer created an account. |
| state | text | US state from the customer's shipping address. |
| acquisition_channel | text | How the customer first found the store. |
Preview the first 5 rowsHide preview
| customer_id | signup_date | state | acquisition_channel |
|---|---|---|---|
| 1 | 2024-09-13 | CO | organic_search |
| 2 | 2025-10-21 | IL | paid_search |
| 3 | 2025-01-17 | AZ | referral |
| 4 | 2024-06-23 | FL | paid_social |
| 5 | 2025-04-08 | IL | paid_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.