Bootcamp
A 60-minute bootcamp that takes one CSV from raw download to a published dashboard. The smallest reproducible analytics loop.
A 60-minute pandas bootcamp
EXAMPLE
# ===== Objectives =====
# 1. Load + inspect a dataset
# 2. Clean and merge it
# 3. Compute KPIs
# 4. Produce one chart
# 5. Publish the chart as a tiny dashboard
# ===== 0-5 min: pick + load =====
# pick a public CSV (e.g. https://data.gov.au, Kaggle, World Bank)
import pandas as pd
df = pd.read_csv('orders.csv', parse_dates=['created_at'], dtype={'status': 'category'})
df.info(memory_usage='deep')
df.head()
df.describe(include='all').T
df.isna().sum().sort_values(ascending=False)
# ===== 5-20 min: clean =====
df['email'] = df['email'].str.strip().str.lower()
df['name'] = df['name'].astype('string').str.title()
df['total_cents'] = df['total_cents'].fillna(0).astype('int64')
df = df.drop_duplicates(subset=['order_id'])
# ===== 20-30 min: join + enrich =====
customers = pd.read_csv('customers.csv', usecols=['id','name','tier'])
df = df.merge(customers, left_on='customer_id', right_on='id', how='left',
suffixes=('','_cust'), indicator=True)
print(df['_merge'].value_counts())
df = df.drop(columns=['_merge', 'id'])
# ===== 30-45 min: KPIs =====
kpis = (df.groupby('tier', observed=True)
.agg(orders=('order_id','count'),
revenue=('total_cents','sum'),
unique_customers=('customer_id','nunique')))
print(kpis.sort_values('revenue', ascending=False))
# Time-series KPI
df = df.set_index('created_at').sort_index()
daily = df['total_cents'].resample('D').sum()
ma7 = daily.rolling(7, min_periods=1).mean()
# ===== 45-55 min: chart =====
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(10, 3))
ax.plot(daily.index, daily.values, alpha=0.4, label='daily')
ax.plot(ma7.index, ma7.values, linewidth=2, label='7-day MA')
ax.legend(); ax.set_title('Daily revenue (cents)')
fig.savefig('daily_revenue.png', dpi=120, bbox_inches='tight')
plt.close(fig)
# ===== 55-60 min: publish =====
# Tiny streamlit dashboard
# streamlit_app.py
# import streamlit as st, pandas as pd
# st.title('Orders dashboard')
# st.dataframe(pd.read_parquet('daily.parquet'))
# st.image('daily_revenue.png')
#
# streamlit run streamlit_app.py
#
# OR host on Hugging Face Spaces / streamlit.io for free.
# Save artifacts
df.to_parquet('orders_clean.parquet', engine='pyarrow', compression='zstd')
daily.to_frame('cents').to_parquet('daily.parquet')
# ===== Patterns to internalise =====
# - parse_dates / dtype upfront -> faster + cleaner
# - indicator=True on merge to detect dropped rows
# - resample / rolling on a DatetimeIndex
# - parquet for downstream sharing (smaller, faster, dtype-preserving)
# - streamlit / gradio for fast dashboards
# ===== Pitfalls =====
# - read_csv with default dtype inference on 1GB+ -> slow + memory hungry
# - apply per row instead of vectorised ops
# - groupby without observed=True on categoricals -> phantom rows
# - merge without indicator -> silent row loss
Why it matters
A 60-minute Saturday bootcamp that ends with a hosted dashboard is the artifact that proves you can do analytics, not just type pandas. Make it real data; ship the dashboard; link it in your portfolio. The streamlit URL is what teams click; the notebook is what they verify.
Tip: Tweak the snippet with Try it Yourself », then sit the quiz at the bottom of the page.
Discussion
Loading…