Python Central HubSign in

Data Analytics with Python / Phase 8: Statistics for Data Analytics

Statistics Mini Project (Analyze a Marketing Campaign)

End-to-end mini project - summarize metrics, build confidence intervals, and run basic tests.

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_id
  • variant (A/B)
  • converted (0/1)
  • revenue
  • country

Step 1: Load

Python
import pandas as pd
 
df = pd.read_csv("data/campaign.csv")
print(df.head())

Step 2: Quick summary

Python
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

diagram Marketing campaign analysis pipeline mermaid
Every step from this phase gets used once: load, describe, estimate, test, and conclude.

Check your understanding

quizCheck yourself
  1. In the group summary, why is conversion_rate computed as the mean of converted?

    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.

  2. Why does the summary include both avg_revenue and median_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.

  3. Which approach does Step 4 use to test the conversion difference?

    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.

  4. What should the final written conclusion address beyond significance?

    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

exerciseYour turn

Tab indents. Press Escape, then Tab, to leave the editor. Control plus Enter runs the code; Control plus Shift plus Enter submits it.

Output
Press Run to see what your code prints.

Exercise 2 – CI on the conversion-rate difference

exerciseYour turn

Tab indents. Press Escape, then Tab, to leave the editor. Control plus Enter runs the code; Control plus Shift plus Enter submits it.

Output
Press Run to see what your code prints.

Exercise 3 – Writing a defensible conclusion

exerciseYour turn

Tab indents. Press Escape, then Tab, to leave the editor. Control plus Enter runs the code; Control plus Shift plus Enter submits it.

Output
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.

Was this page helpful?

Let us know how we did