A complete AI agency at your fingertips - From frontend wizards to Reddit community ninjas, from whimsy injectors to reality checkers. Each agent is a specialized expert with personality, processes, and proven deliverables.
Shell
fix(analytics): count orders instead of order lines in RFM
Rudy Celekliffce970fc66a
diff --git a/support/support-analytics-reporter.md b/support/support-analytics-reporter.mdindex 84d282b7..7b4892fd 100644--- a/support/support-analytics-reporter.md+++ b/support/support-analytics-reporter.md@@ -92,6 +92,9 @@ ORDER BY month DESC;```### Customer Segmentation Analysis++Input rows may represent individual order lines. Sum their revenue, and count distinct order IDs per customer when calculating purchase frequency.+```pythonimport pandas as pdimport numpy as np@@ -108,7 +111,7 @@ def customer_segmentation_analysis(df):current_date = df['date'].max()rfm = df.groupby('customer_id').agg({'date': lambda x: (current_date - x.max()).days, # Recency- 'order_id': 'count', # Frequency+ 'order_id': 'nunique', # Frequency: distinct orders'revenue': 'sum' # Monetary}).rename(columns={'date': 'recency',