Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Business framing: Projects are how you show impact — automate a report, build a small ML predictor, or deploy a microservice. This starter cell gives a minimal, reproducible project scaffold you can run in-browser (Pyodide-safe) to understand data flow, testing, and automation.



Visual intuition: Project pipeline

Caption: A compact project pipeline: collect, clean, transform, model, serve, and monitor.


MCQ

  • Q: Which part of the project should contain idempotent operations suitable for retries (e.g., avoiding duplicate reports)?

    • A) Data collection

    • B) Reporting/serving endpoints with idempotency keys

    • C) Feature engineering

    • (Answer: B)

Exercises

  1. Extend the starter to write sample rows to a CSV file (simulate by printing CSV lines). Add a small test that asserts the length of generated rows.

  2. Add a command-line-like run() function that accepts --days N and returns the summary; show how you would schedule it with cron (explain in a markdown cell).

  3. (Stretch) Replace the summary with a tiny linear-regression predictor using only NumPy and show predicted next-day revenue.


Notes: This starter uses only the standard library for Pyodide compatibility. For full production, swap the scaffold to use pandas and proper persistence.

# Project runner + CSV export simulation + quick test

def run_project(days=7):
    sample = generate_sales(days)
    summary = daily_summary(sample)
    # Simulated CSV export (print lines so Pyodide can capture)
    print('date,revenue,orders')
    for r in sample:
        print(f"{r['date']},{r['revenue']},{r['orders']}")
    print('\nSUMMARY:', summary)
    return sample, summary

# Quick smoke test
rows, summ = run_project(3)
assert len(rows) == 3, 'Expected 3 rows'
print('Smoke test passed: generated', len(rows), 'rows')

Practical Projects and Exercises

Exercises

Exercise 1 — CSV export (Pyodide-safe)


Exercise 2 — CLI-style run() wrapper


Exercise 3 — Rolling average and prediction sketch


Exercise 4 — Quick smoke test


Exercise 5 — Project extension idea (freeform)

  • Add a small scheduler wrapper that accepts dry_run and --days and logs idempotency keys for exported reports.

  • Optional: sketch how you would add a tiny Flask endpoint to serve the CSV (describe in a markdown cell).