Goal
Given a marketing campaign dataset, you will:
- compute descriptive statistics
- compare two segments (A vs B)
- build confidence intervals
- produce a short written conclusion
Example dataset columns
user_idvariant(A/B)converted(0/1)revenuecountry
Step 1: Load
import pandas as pd
df = pd.read_csv("data/campaign.csv")
print(df.head())Step 2: Quick summary
summary = (
df.groupby("variant")
.agg(
users=("user_id", "nunique"),
conversion_rate=("converted", "mean"),
avg_revenue=("revenue", "mean"),
median_revenue=("revenue", "median"),
)
)
print(summary)Step 3: Visualize
Use either Matplotlib/Seaborn/Plotly:
- conversion bar chart
- revenue distribution comparison
Step 4: Test conversion difference (approx)
Use the “A/B Testing Basics” approach.
Step 5: Deliverable
Write a short conclusion:
- Does variant B improve conversion?
- Is the result practically meaningful?
- Any data quality concerns?
The project pipeline
flowchart LR A["Load campaign.csv"] --> B["Descriptive stats
per variant"] B --> C["Confidence interval
on conversion rate"] C --> D["A/B test
(z-test or t-test)"] D --> E["Written conclusion"]
Check your understanding
In the group summary, why is conversion_rate computed as the mean of converted?
For a 0/1 column the mean is the conversion rate.
Show answer
A — Because converted is 0 or 1, so its mean is the share of converters — For a 0/1 column the mean is the conversion rate.
Why does the summary include both avg_revenue and median_revenue?
Comparing mean and median shows skew and outlier influence on revenue.
Show answer
A — Revenue is often skewed, so the median guards against outliers — Comparing mean and median shows skew and outlier influence on revenue.
Which approach does Step 4 use to test the conversion difference?
Conversion is a proportion per variant, so the A/B approach with a two-proportion test applies.
Show answer
B — The two-proportion z-test from A/B Testing Basics — Conversion is a proportion per variant, so the A/B approach with a two-proportion test applies.
What should the final written conclusion address beyond significance?
The deliverable asks if B improves conversion, if it is practically meaningful and about data quality.
Show answer
A — Whether the result is practically meaningful, plus any data quality concerns — The deliverable asks if B improves conversion, if it is practically meaningful and about data quality.
🧪 Try It Yourself
Exercise 1 – Descriptive summary by variant
Tab indents. Press Escape, then Tab, to leave the editor. Control plus Enter runs the code; Control plus Shift plus Enter submits it.
Press Run to see what your code prints.Exercise 2 – CI on the conversion-rate difference
Tab indents. Press Escape, then Tab, to leave the editor. Control plus Enter runs the code; Control plus Shift plus Enter submits it.
Press Run to see what your code prints.Exercise 3 – Writing a defensible conclusion
Tab indents. Press Escape, then Tab, to leave the editor. Control plus Enter runs the code; Control plus Shift plus Enter submits it.
Press Run to see what your code prints.Next
This wraps up the Statistics phase. Carry these tools — descriptive stats, confidence intervals, and hypothesis testing — into modeling and machine learning, where the same ideas reappear as regression diagnostics and model evaluation metrics.