Skip to content

Data dictionary

This page describes every file in the course data. Lessons cite these numbers, so use it to check your own results. To get the files, follow Get the data.

  • Unzip course-data.zip into your project folder. The folder data/ appears there, so your code uses paths like data/sales.csv.
  • The whole data/ folder has 32 files and 6,786,288 bytes. The zip file is 1,276,941 bytes.
  • Money is in US dollars, rounded to 2 decimals. Dates use the ISO form YYYY-MM-DD unless a quirk says otherwise.
  • CSV files are UTF-8 text with \n line endings. The one exception is legacy_latin1.csv.
  • With pandas 3, text columns load as the str dtype. Integer columns that contain blanks load as float64, for example visits and lot_sqft.
  • The numbers below were measured on these exact files.
Path Rows / size Use
data/stores.csv 12 rows dimension table
data/products.csv 30 rows dimension table
data/customers.csv 5,000 rows churn classification
data/sales.csv 20,228 rows analysis, joins, forecasting
data/sales_raw.csv 1,200 rows data cleaning
data/sales_sample.xlsx 500 rows Excel I/O
data/sales_sample.parquet 500 rows Parquet I/O
data/houses.csv 3,000 rows regression
data/web_traffic.csv 1,096 rows time series
data/reviews.csv 3,000 rows NLP
data/sensors.csv 8,064 rows time series, anomalies
data/readings.txt 43 lines beginner file reading
data/ab_test.csv 10,000 rows hypothesis testing
data/logs/app.log 500 lines regex, parsing
data/reports/2024-01.csv … 2024-06.csv 47–55 rows each folder processing
data/config.json 1 object JSON, config
data/customers.json 20 records nested JSON
data/messy_names.txt 20 lines strings, Unicode
data/legacy_latin1.csv 12 rows encodings
data/shop.db 4 tables SQL
data/api/*.json, data/api/catalog.html 7 files APIs, BeautifulSoup

A key is a column that identifies a row. A foreign key points to the key of another table. The diagram shows how the tables connect.

erDiagram
    stores ||--o{ sales : store_id
    products ||--o{ sales : product_id
    customers ||--o{ sales : customer_id
    products ||--o{ reviews : product_id
    sales ||--o{ reports : order_id
    customers ||--o| customers_json : customer_id
  • sales.store_id points to stores.store_id. sales.region always equals the store’s region.
  • sales.product_id points to products.product_id. sales.product, category and unit_price always equal the product row.
  • sales.customer_id points to customers.customer_id. Every id exists. No order is dated before the customer’s signup_date. 3,254 of 5,000 customers have orders. The store region matches the customer’s region on 88.9% of lines. The rest are out-of-region visits and online orders that another store fulfilled.
  • reviews.product_id points to products.product_id. No review predates the product launch.
  • sales_raw, sales_sample.*, reports/* and shop.db.orders are subsets or copies of sales.csv. The orders in customers.json are real orders from sales.csv.
  • The API files use the product ids and the review ratings.
  • ab_test, houses, web_traffic and sensors stand alone.

12 rows, one per store. Primary key: store_id.

Column Dtype Meaning
store_id str S01..S12
city str US city
region str North, South, East, West (3 stores each)
size_sqm int floor area, 1,350–3,400 m²
opened str (date) opening date
store_id city region size_sqm opened sales lines
S01 Chicago North 2,850 2009-03-14 2,220
S02 Minneapolis North 1,950 2012-08-01 1,563
S03 Detroit North 1,420 2016-05-21 1,183
S04 Houston South 3,100 2008-11-08 2,199
S05 Atlanta South 2,300 2011-04-16 1,745
S06 Miami South 1,680 2018-09-29 1,200
S07 New York East 3,400 2008-02-23 2,541
S08 Boston East 2,050 2013-10-12 1,541
S09 Philadelphia East 1,760 2017-03-04 1,314
S10 Seattle West 2,480 2010-06-19 2,190
S11 San Francisco West 1,890 2014-07-26 1,664
S12 Denver West 1,350 2023-06-15 868

Quirk: S12 opened on 2023-06-15, inside the sales period. It has no sales before that date. Sales volume scales with size_sqm.

30 rows, 5 per category. Primary key: product_id.

Column Dtype Meaning
product_id str P001..P030
product str readable name (one contains an apostrophe: Chef's Knife Set)
category str Electronics, Home, Clothing, Sports, Books, Beauty
unit_cost float cost to the shop, 4.10–845.00
unit_price float list price, 14.99–1,299.00 (mean 177.61, median 74.99)
launch_date str (date) 2019-01-22..2024-04-09
product_id product category unit_cost unit_price launch_date sales lines mean rating
P001 Wireless Earbuds Electronics 31.50 79.99 2021-03-01 1,375 3.8
P002 Noise-Cancelling Headphones Electronics 104.00 249.00 2020-10-15 856 3.91
P003 55-inch 4K Smart TV Electronics 845.00 1299.00 2021-09-01 427 3.98
P004 14-inch Ultrabook Laptop Electronics 780.00 1149.00 2022-02-10 532 3.96
P005 Smartwatch Series 5 Electronics 88.00 199.99 2023-09-12 752 3.47
P006 Espresso Machine Home 162.00 349.00 2020-04-20 479 4.01
P007 Robot Vacuum Home 141.00 299.99 2024-02-20 367 3.09
P008 Chef’s Knife Set Home 48.00 129.95 2019-11-05 707 4.15
P009 Air Purifier Home 83.00 189.00 2021-01-18 597 3.92
P010 Cotton Bed Sheet Set Home 24.00 69.99 2019-06-03 1,115 3.95
P011 Waterproof Rain Jacket Clothing 44.00 119.00 2020-09-01 561 3.83
P012 Merino Wool Sweater Clothing 31.00 89.50 2021-10-04 522 3.96
P013 Slim Fit Jeans Clothing 19.50 59.99 2019-02-11 836 3.34
P014 Running Socks 3-Pack Clothing 4.20 14.99 2019-05-27 966 3.88
P015 Organic Cotton T-Shirt Clothing 6.10 19.99 2020-03-16 1,129 3.8
P016 Trail Running Shoes Sports 52.00 129.99 2021-04-12 786 3.89
P017 Non-Slip Yoga Mat Sports 11.00 34.99 2019-08-19 975 3.8
P018 Adjustable Dumbbells Sports 128.00 279.00 2020-12-01 436 4.28
P019 Fitness Tracker Sports 39.00 99.99 2023-05-02 713 3.82
P020 2-Person Camping Tent Sports 76.00 189.99 2022-03-07 421 3.89
P021 Harbor Lane Mysteries Books 5.40 16.99 2021-06-08 790 4.21
P022 Weeknight Kitchen Cookbook Books 9.80 29.99 2020-10-27 593 3.99
P023 A Brief History of Maps Books 7.90 24.50 2022-09-13 421 3.71
P024 Statistics Made Simple Books 11.20 34.99 2019-01-22 526 3.64
P025 The Mindful Runner Books 4.60 14.99 2024-04-09 237 3.97
P026 Vitamin C Face Serum Beauty 6.30 24.99 2021-02-01 713 3.65
P027 Hydrating Face Cream Beauty 9.10 32.00 2020-05-11 593 3.97
P028 Shampoo and Conditioner Set Beauty 6.80 21.50 2019-09-30 654 3.78
P029 Electric Toothbrush Beauty 22.00 59.99 2022-01-17 408 4.07
P030 Mineral Sunscreen SPF 50 Beauty 4.10 15.99 2019-04-15 741 3.79

Quirks: four products launch inside the sales period (P019 on 2023-05-02, P005 on 2023-09-12, P007 on 2024-02-20, P025 on 2024-04-09). Their first sale is on the launch day. Book titles are invented.

5,000 rows, one per subscription customer. The snapshot date is 2024-12-31. Primary key: customer_id. Ids increase with signup_date, so C00001 is the oldest customer.

Column Dtype Meaning and range
customer_id str C00001..C05000
signup_date str (date) 2018-12-01..2024-12-27
age int 18–80, mean 42.3
region str East 1,416, South 1,268, North 1,225, West 1,091
plan str basic 2,028, standard 1,982, premium 990
contract str month-to-month 2,784, one-year 1,225, two-year 991
payment_method str electronic_check 1,563, credit_card 1,360, bank_transfer 1,209, paypal 868
has_autopay int 0/1 52.9% are 1; rare with electronic_check
tenure_months int 0–72, mean 23.1, median 17
monthly_charges float 28.05–143.24, mean 60.84; depends on plan
total_charges float 29.55–8,322.61; about monthly_charges × tenure_months (within 6%)
support_tickets int 0–9, mean 1.24
logins_last_30d int 0–60, mean 11.7
avg_session_minutes float 1.0–68.1, mean 14.3
churned int 0/1 target: the customer churned in the last month

Headline facts:

  • Churn rate: 19.26% (963 of 5,000).
  • Churn by contract: month-to-month 29.6%, one-year 8.8%, two-year 3.2%.
  • Churn by payment: electronic_check 24.8%, bank_transfer 17.4%, paypal 17.4%, credit_card 15.8%.
  • Churn by plan: premium 29.6% (high charges), basic 17.4%, standard 16.0%.
  • Tenure of 1–6 months: 44.4% churn. logins_last_30d <= 3: 42.5% churn.
  • Churn rises with tickets: 13.2% at 0 tickets, 32.6% at 3, 47.3% at 4.

Quirks:

  • total_charges is blank for exactly 10 brand-new customers (tenure_months 0, signup in December 2024, C04991..C05000). They never churned. pd.read_csv reads them as NaN.
  • 72 months is a cap: customers who signed up on 2018-12-01 pile up at tenure_months 72.
  • The classes are imbalanced, about 1 churned customer to 4 who stayed.

These scores are a baseline to compare your own models against. The features are every column except customer_id, signup_date and churned. The split is train_test_split(test_size=0.25, stratify=y, random_state=42).

Model Hold-out ROC-AUC 5-fold stratified CV ROC-AUC (mean)
LogisticRegression(max_iter=1000) + one-hot + median impute + StandardScaler 0.813 0.814
HistGradientBoostingClassifier(random_state=42, categorical_features="from_dtype") 0.825 0.831
same, learning_rate=0.05, max_iter=300, max_leaf_nodes=15, early_stopping=True 0.837 0.847

Cross-validation (CV) is StratifiedKFold(5, shuffle=True, random_state=42). For gradient boosting, the four text columns were cast to category.

20,228 order lines from 2023-01-01 to 2024-12-31. The file is sorted by order_date, then order_id. One order has 1–3 lines with distinct products. order_id is not unique, but the pair (order_id, product_id) is unique.

Column Dtype Meaning and range
order_id str O000001..O014877 (14,877 orders), increases with date
order_date str (date) every day of 2023–2024 has orders (731 days)
customer_id str points to customers
store_id str points to stores; for online orders, the fulfilling store
region str region of the store
channel str store 11,733, online 8,495
product_id str points to products
product str product name
category str Clothing 4,014, Electronics 3,942, Sports 3,331, Home 3,265, Beauty 3,109, Books 2,567 lines
unit_price float list price, equals products.unit_price (no price changes)
quantity int 1–25, mean 1.46; 1: 72%; 29 bulk lines with 10–25 units
discount float 0.0, 0.05, 0.1, 0.2
revenue float unit_price * quantity * (1 - discount), rounded to cents with np.round. For a few rows, Python’s built-in round() gives 0.01 less (float representation), so compare with a tolerance of 0.01.

Headline facts:

  • Total revenue 3,596,523.83. For 2023: 1,645,589.59. For 2024: 1,950,934.24 (+18.6%). Lines: 9,081 in 2023 and 11,147 in 2024. Units: 29,533.
  • Mean line revenue 177.80, median 79.99. Gross profit (revenue minus unit_cost × quantity) is 1,760,135.83. The margin is 48.9%.
  • Revenue by category: Electronics 1,808,108, Home 672,295, Sports 544,109, Clothing 314,687, Beauty 150,418, Books 106,908. Electronics is 19% of lines but 50% of revenue.
  • Revenue by region: East 993,684, South 891,766, North 888,229, West 822,845.
  • Online share: 42.0% overall, 36.8% in 2023, 46.2% in 2024.
  • 27.6% of orders have more than one line.
  • Discount mix: 0: 67.5%, 0.05: 13.1%, 0.1: 12.3%, 0.2: 7.1%. Deeper discounts appear on promo days and in December.

Time-series structure (aggregate with groupby("order_date")):

  • Daily revenue: mean 4,920.01, median 4,217.61. Daily units: mean 40.4. Orders per day: mean 20.4.
  • Trend: volume grows about 45% from the start to the end of the period.
  • Weekly pattern: Saturday is the peak. Mean daily revenue: Sat 6,365, Sun 5,636, Fri 5,598, Thu 4,416, Wed 4,259, Mon 4,233, Tue 3,943.
  • Yearly pattern: November–December peak and January–February dip. Sports peaks in June–August (Sports lines per month: Jun 387, Jul 393, Aug 351, Feb 163). Electronics demand nearly doubles in November–December. Beauty has a small February bump.
  • Monthly revenue: lowest 2023-02 (77,405) and highest 2024-12 (302,912). Also 2023-12: 241,098 and 2024-11: 268,467.
  • Promo days (built into volume and discounts): Black Friday 2023-11-24 and 2024-11-29 (the two largest days: 31,222.69 and 33,619.18). The following weekend and Cyber Monday (2023-11-27, 2024-12-02). Summer sales on 2023-07-11/12 and 2024-07-16/17. Low days: Thanksgiving and 2024-01-01.
  • On 2023-12-25 and 2024-12-25 the stores are closed, so all orders are online.
  • Seasonal-naive (lag 7) MAE on the last 92 days: units 23.9 (mean 63.9), revenue 3,801.5 (mean 8,016.6). Daily revenue is noisy because of high-price electronics. Daily units or weekly revenue are smoother targets.

1,200 rows with the same 13 columns as sales.csv, for the cleaning module. It is a random sample of 1,164 sales lines (sorted by date) plus 36 exact duplicate rows. Each duplicate sits up to 30 rows after its original. The table lists all injected problems, counted in the file:

Problem Column Count
Exact duplicate rows (df.duplicated().sum()) all 36
Date as DD/MM/YYYY (day first, for example 07/01/2023 is 7 January) order_date 276
Date as Month D, YYYY (for example January 7, 2023) order_date 201
Date as ISO YYYY-MM-DD order_date 723
Region in wrong case or with spaces (north, NORTH, North, North ) region 259
Missing token ("" 7, N/A 7, - 3) region 17
Missing token (N/A 12, "" 6, - 5) customer_id 23
Missing token (N/A 9, "" 4, - 4) channel 17
Missing token ("" 9, N/A 8, - 7) discount 24
Missing token ("" 6, N/A 2, - 2) unit_price 10
Price as text with a dollar sign ($79.99) unit_price 1,190
…of which with a thousands separator ("$1,299.00", quoted) unit_price 47
Stray spaces in product name (29 leading, 35 trailing, 31 double inner) product 95
Negative quantity (-3, -2, -2, -2, -1, -1) quantity 6
Absurd quantity (250, 500, 999, 1000) quantity 4

Notes:

  • revenue is the original, correct value. On the 10 bad-quantity rows, it does not equal unit_price × quantity × (1 - discount).
  • The duplicates are copies made after the corruption, so drop_duplicates() removes all 36.
  • pd.read_csv treats "" and N/A as NaN by default, but not -. Use na_values=["-"], or ["", "N/A", "-"] as in config.json.
  • Do not use pd.to_datetime(df["order_date"], format="mixed", dayfirst=True). It parses all 1,200 dates without an error, but it reads 269 ISO dates as year-day-month (2023-01-04 becomes 2023-04-01). Parse each of the three formats with an explicit format= and errors="coerce", then combine them. Module 26 shows how.
  • quantity has no missing values and loads as int64. discount and unit_price load as text.

data/sales_sample.xlsx and data/sales_sample.parquet

Section titled “data/sales_sample.xlsx and data/sales_sample.parquet”

The first 500 rows of sales.csv (2023-01-01..2023-01-28), with the same 13 columns. order_date is a real date: an Excel date cell (format YYYY-MM-DD, sheet name sales) and a Parquet timestamp column. pd.read_excel and pd.read_parquet return it as datetime64. All other values equal sales.csv.

3,000 house sales from 2022-01-03 to 2024-12-30. The file is sorted by sold_date. Primary key: house_id.

Column Dtype Meaning and range
house_id str H0001..H3000
neighborhood str 8 values (counts below)
sqft int 550–5,710, median 1,740 (multiple of 10)
bedrooms int 1–7, mean 3.0
bathrooms float 1.0–5.5 in steps of 0.5
year_built int 1905–2023; always before the sale year
lot_sqft int, 90 blank 880–39,180, median 7,530; grows with distance
garage_spaces int 0–3 (often 0 near the center)
has_pool int 0/1 10.9%
condition int 1–5, mean 3.0; older houses are in worse condition
distance_to_center_km float 0.2–20.2
school_rating int, 90 blank 1–10, mean 6.5
sold_date str (date) 2022-01-03..2024-12-30
price int 117,500–3,730,500; median 376,000; mean 476,466 (multiple of 500)

Median price and count by neighborhood: Cedar Park 249,000 (407), Westfield 266,750 (450), Old Town 335,250 (276), Downtown 341,750 (356), Maple Grove 402,750 (454), Riverside 476,750 (370), Oak Hill 724,500 (380), Lakeview 777,000 (307).

Quirks:

  • Missing values: lot_sqft 90 (3.0%) and school_rating 90 (3.0%). The blanks are placed completely at random (MCAR), and the two columns are blank independently of each other.
  • 8 injected price outliers. Five are inflated by a factor of 2.2–3.0: H0537 (Westfield, 1,040 sqft, 500,500), H0542 (Maple Grove, 3,770 sqft, 2,660,000), H0751 (Oak Hill, 1,370 sqft, 1,431,000), H0914 (Cedar Park, 1,730 sqft, 719,500) and H2277 (Old Town, 1,080 sqft, 905,500). Three are deflated by a factor of 0.35–0.5: H0887 (Lakeview, 1,560 sqft, 252,500), H0957 (Old Town, 1,160 sqft, 117,500) and H1990 (Oak Hill, 1,620 sqft, 273,500). Large Lakeview and Oak Hill houses above 1.9 million are genuine.
  • Price is right-skewed. Log price is close to normal.

These scores are a baseline to compare your own models against. The features are all columns except house_id, sold_date and price, with one-hot neighborhood, median imputing and StandardScaler. The split is train_test_split(test_size=0.25, random_state=42).

Model Target Hold-out R² 5-fold CV R² (KFold(5, shuffle=True, random_state=42))
LinearRegression price 0.792 0.799, 0.807, 0.799, 0.764, 0.781
LinearRegression log(price) 0.892 0.902, 0.891, 0.891, 0.888, 0.893
HistGradientBoostingRegressor(random_state=42) price 0.909 0.912, 0.901, 0.923, 0.874, 0.872
HistGradientBoostingRegressor(random_state=42) log(price) 0.919 0.920, 0.919, 0.910, 0.910, 0.911

Teaching points: the log transform helps the linear model a lot. Gradient boosting handles NaN natively (with neighborhood as category).

1,096 rows, one per day, from 2022-01-01 to 2024-12-31. No dates are missing.

Column Dtype Meaning and range
date str (date) daily, consecutive
visits int, 5 blank 2,576–18,385, mean 4,356
unique_visitors int 71–79% of visits (1,869–14,275)
signups int 31–374; about 2.2% of unique visitors (higher during campaigns)
bounce_rate float 0.353–0.552, mean 0.433 (higher during campaigns)
marketing_spend float 270.76–5,026.30 per day, mean 622.58

Structure:

  • Trend: mean visits are 3,512 (2022), 4,058 (2023) and 5,497 (2024). Growth is exponential, plus a slow random-walk level.
  • Weekly pattern: weekday peak and weekend dip. Mean visits: Tue 4,861, Mon 4,820, Wed 4,650, Thu 4,442, Fri 4,108, Sun 3,949, Sat 3,671.
  • Yearly pattern: November–December peak (December mean 5,242) and July low (3,869).
  • Day-to-day noise is AR(1)-style: ACF lag 1 = 0.808, lag 7 = 0.538.
  • 7 marketing campaigns (spend rises by 2,500–4,500 per day, 34 high-spend days). They start on 2022-03-14, 2022-09-06, 2023-02-20, 2023-06-12, 2023-10-02, 2024-04-08 and 2024-09-16. Visits spike on day one and decay over about a week. The top day is 2024-04-08 with 18,385 visits. The correlation between spend and visits is 0.604.
  • Stationarity (statsmodels adfuller, visits interpolated): constant only gives p = 0.114 (not stationary). With trend (regression="ct"), p = 0.0001. The first difference gives p ≈ 1e-19.

Quirk: visits is blank (a tracking outage) on 2022-08-11, 2022-08-24, 2023-05-24, 2024-05-29 and 2024-10-25. The other columns are complete on those days. Use interpolate() or ffill().

3,000 product reviews from 2023-01-01 to 2024-12-31. The file is sorted by review_date. Primary key: review_id.

Column Dtype Meaning and range
review_id str R00001..R03000
product_id str points to products; popular products get more reviews
product str product name
category str Electronics 591, Clothing 588, Home 504, Sports 478, Beauty 442, Books 397
rating int 1: 330, 2: 266, 3: 338, 4: 687, 5: 1,379 (mean 3.84)
title str 20 distinct short titles (by tone); 51 are empty
text str 3–52 words, mean 16.2
review_date str (date) at least 7 days after launch
sentiment str positive (rating 4 or 5) 2,066, negative (rating 1 or 2) 596, neutral (rating 3) 338

About the text: each review has 1–3 sentences about aspects such as quality, delivery, price and value, customer service, durability, battery, size and fit, and ease of use. Each product has its own aspects. Battery appears only for battery devices, and size and fit only for clothing and shoes. Sentences use intensifiers (“really”, “super”, “extremely”) and negations (“not worth it”, “not cheap quality at all”, “never replied”). Some reviews have an opener (“Bought this for my son.”) or a closer (“Would buy again.”, “Never again.”). Ratings 2 and 4 are often mixed (“But …”, “However, …”). Rating 3 mixes a positive and a negative sentence, or is neutral. About 6% of the reviews with rating 1, 2, 4 or 5 have text with the opposite tone (a mis-clicked rating), so accuracy cannot reach 1.0. Products differ in mean rating: Robot Vacuum 3.09, Slim Fit Jeans 3.34 and Smartwatch Series 5 3.47 are low. Adjustable Dumbbells 4.28 and Harbor Lane Mysteries 4.21 are high.

Quirks (counts of reviews):

Quirk Count
Typo (recieved, definately, qualty, teh, recomend, batery, …) 170
Leading or trailing whitespace 95
Double space between sentences 96
Line break inside the text (quoted in the CSV) 23
HTML entity &amp; 54
HTML entity &#39; (apostrophe) 8
Whole text in upper case 39
Shout with !!! (NEVER AGAIN!!!, LOVE IT!!!) 89
Empty title 51

Read the file with keep_default_na=False to keep empty titles as "". Because of the line breaks, the file has more lines than rows. Use a CSV parser, not splitlines().

These scores are a baseline to compare your own models against. They use positive and negative reviews only (2,662 rows), with text as the only feature and train_test_split(test_size=0.25, stratify=y, random_state=42).

Model Accuracy Notes
Majority class (positive) 0.776
TfidfVectorizer() + LogisticRegression(max_iter=1000) 0.901 F1 (negative) 0.763; 5-fold CV mean 0.896
TfidfVectorizer(ngram_range=(1, 2), min_df=2) + same 0.893

Topic modeling: TfidfVectorizer(stop_words="english", min_df=5, max_df=0.5) + NMF(10, init="nndsvda", random_state=42, max_iter=1000) gives these top words (first 6 per topic):

  • price: price point beat stores lower hard
  • battery: battery charge holds days fast charges
  • durability: months lasted durable use daily signs
  • quality: feels material quality premium cheap solid
  • customer service: great customer service question looks attention
  • value and delivery: money value delivery worth excellent time
  • refunds and shipping: day refund seller processed weeks using
  • size and fit: size true fit fits perfect glove
  • recommendation: recommend friends definitely highly helpful package
  • a mixed topic

With 8 topics, size and fit merges into the recommendation topic. Ease of use shares products with battery and often merges with it. The token amp appears until you unescape the HTML entities.

8,064 rows: 4 sensors × 2,016 ten-minute readings, from 2024-05-01T00:00:00 to 2024-05-14T23:50:00. The file is sorted by timestamp, then sensor_id. Key: (timestamp, sensor_id).

Column Dtype Meaning and range
timestamp str (ISO datetime YYYY-MM-DDTHH:MM:SS) every 10 minutes
sensor_id str S1, S2, S3, S4
temperature_c float, 22 blank 18.56–44.89, mean 24.06
humidity_pct float, 29 blank 42.8–63.6, mean 54.1; moves against temperature
vibration_mm_s float, 30 blank 1.13–18.98, median 2.4
status str ok 7,587, warn 453, fail 24

Structure:

  • Daily temperature cycle: minimum about 03:00, maximum about 15:00. Mean temperature: S1 22.05, S2 24.60, S3 23.53, S4 26.04.
  • Drift: S3 temperature rises about 0.35 °C per day (daily mean 21.29 on May 1 and 25.85 on May 14). This is calibration drift.
  • Wear: S4 vibration rises from May 12. The daily median is about 3.1 until May 11, then 5.06, 6.71 and 8.77. Most warn rows are S4 (400 of 453).
  • Status rule, computed before the blanks were added: fail if vibration is at least 11.2 or temperature is at least 42. warn if vibration is at least 4.5 or temperature is at least 33. Otherwise ok. Status by sensor: S1 14 warn; S2 17 warn, 5 fail; S3 22 warn; S4 400 warn, 19 fail.
  • Anomalies: 81 spikes (1%). 40 are temperature spikes of +9 to +18 °C. 41 are vibration spikes of ×3 to ×5.
  • Missing values: 81 blank cells (1%), spread over the three numeric columns. status is never blank.

43 lines, one temperature reading (°C) per line. 40 lines are valid values from 19.3 to 22.9 (mean 21.06). 3 lines are invalid: error (line 12), an empty line (line 24) and n/a (line 35). The file ends with a newline. Use it with float() and try/except ValueError.

10,000 users in a checkout-page A/B test. Primary key: user_id.

Column Dtype Meaning and range
user_id str U00001..U10000
group str control 5,002, treatment 4,998 (random assignment)
device str mobile 5,577, desktop 3,428, tablet 995
country str US 3,880, UK 1,519, DE 1,217, CA 1,066, FR 1,006, AU 808, IN 504
converted int 0/1 overall 10.9%
revenue float 0 unless converted; log-normal for buyers, 4.62–276.66 (median 35.03)
time_on_page_s float 1.6–450.3, mean 87.2

Headline facts:

  • Conversion: control 10.12%, treatment 11.66%. Relative lift: +15.3%.
  • Two-proportion z-test (pooled): z = 2.486, two-sided p = 0.0129.
  • Revenue per user: control 4.38, treatment 4.85. Average order value of buyers: control 43.30, treatment 41.54. There is no real difference, because revenue per buyer has the same distribution in both groups.
  • Conversion by device: desktop 13.24%, tablet 11.96%, mobile 9.25%.
  • Mean time on page: control 82.7 s, treatment 91.8 s. Buyers stay longer.

500 lines from a data pipeline and its API, from 2024-05-01 08:04:01,354 to 2024-05-01 19:57:28,996. The line format is:

2024-05-01 08:08:39,278 INFO [api] 172.16.4.9 POST /api/v1/predict 201 93ms user=mei.chen@example.org
2024-05-01 08:25:13,950 INFO [loader] Loaded 20000 rows from sales.csv in 0.55s

A regex for a normal line:

^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}),(\d{3}) (\w+) \[(\w+)\] (.*)$

It matches 492 of 500 lines. The other 8 are traceback lines. An API request message has the form <ip> <METHOD> <path> <status> <ms>ms user=<email or ->.

  • Levels: INFO 447, WARNING 25, DEBUG 13, ERROR 7.
  • Components: api 391, loader 29, pipeline 18, cache 13, model 12, validator 9, cleaner 9, exporter 9, db 2.
  • 9 pipeline runs (Starting pipeline run-0001 … Finished run-0009 status=success) with loader, validator, cleaner, model (roc_auc=0.8xx) and exporter lines.
  • HTTP status codes: 200: 250, 201: 77, 304: 10, 400: 11, 401: 7, 404: 13, 422: 7, 429: 13, 500: 3. Status 500 is logged as ERROR and 429 as WARNING. The file has no Slow request: lines, because no request is slower than the 1,500 ms threshold.
  • 8 distinct emails (all example.com, example.org or example.net). 7 distinct IPs (private ranges plus the documentation ranges 203.0.113.x and 198.51.100.x).
  • Quirk: 2 multi-line Python tracebacks (4 lines each, 8 lines in total) follow an ERROR line. These lines do not start with a timestamp.

Six monthly extracts of sales.csv: 2024-01.csv to 2024-06.csv. Each is a random subset of that month’s lines, sorted by date.

File Rows Revenue sum
2024-01.csv 48 14,162.33
2024-02.csv 48 4,719.04
2024-03.csv 47 12,296.72
2024-04.csv 52 10,879.04
2024-05.csv 47 6,675.86
2024-06.csv 55 8,533.40

Columns: order_id, order_date, store_id, product, category, quantity, revenue.

Quirk: 2024-04.csv has the same columns in a different order: order_date, order_id, store_id, category, product, revenue, quantity. pd.concat aligns by name. Naive line concatenation does not.

A pipeline config. Top-level keys:

  • project (“sales-pipeline”) and version (“1.4.0”).
  • input: paths to sales, customers, products, stores and reports_dir.
  • output: dir, format and overwrite (false).
  • columns: 9 sales column names.
  • date_columns.
  • thresholds: min_quantity 1, max_quantity 50, max_discount 0.2, max_missing_fraction 0.05 and churn_probability 0.5.
  • cleaning: drop_duplicates, strip_whitespace, na_values (["", "N/A", "-"]) and date_formats (["%Y-%m-%d", "%d/%m/%Y", "%B %d, %Y"]).
  • model: type, target (“churned”), test_size 0.25, random_state 42 and params (C 1.0, max_iter 1000).
  • logging.
  • retry: attempts 3 and backoff_seconds ([1, 2, 4]).

The thresholds and formats match sales_raw.csv.

The top-level object has the keys exported_at (“2025-01-02T06:00:00Z”), count (20) and customers (a list). The records are for C00001..C00020. Their signup_date and plan match customers.csv. Each record has:

  • customer_id, name, email (first.last@example.com), signup_date and plan.
  • address: street, city (a store city in the customer’s region), region and postal_code.
  • tags: a sorted list.
  • orders: a list of objects with order_id, date, items and amount. It holds up to the first 5 real orders from sales.csv. amount is the order revenue.

Quirks for defensive parsing:

  • 48 orders in total.
  • 3 customers have an empty orders list. 5 have an empty tags list.
  • postal_code is missing for C00005 and C00014.
  • phone is null for C00010, present for 6 customers and absent for the rest.
  • Some names and emails also appear in logs/app.log.

20 UTF-8 lines of person names with odd spacing, casing and accents. Examples: " josé GARCÍA ", "ZOË o'brien", "ÇAĞLA yılmaz", "NGUYỄN văn an" and "o'neill, PATRICK" (last name first).

Lines 8 (José García) and 13 (Zoë O'Brien) are in Unicode NFD form, with decomposed accents. They look equal to the NFC spellings, but == is False until you call unicodedata.normalize("NFC", ...). After stripping, collapsing spaces, title case and NFC, lines 1 and 8 are duplicates, and so are lines 2 and 13.

12 supplier rows plus a header, encoded in latin-1 (ISO-8859-1). Columns: supplier_id (SUP01..SUP12), supplier (for example Café Müller GmbH), city (for example Köln, Málaga, Zürich, São Paulo, Montréal, Asunción), country and since (year). Reading it as UTF-8 raises UnicodeDecodeError. Use encoding="latin-1".

A SQLite database with four tables and foreign keys. SQLite enforces foreign keys only after PRAGMA foreign_keys = ON.

Table Rows Primary key Columns
stores 12 store_id same as stores.csv
products 30 product_id same as products.csv
customers 5,000 customer_id same as customers.csv; total_charges is NULL for 10 rows
orders 20,228 line_id (1..20,228, in sales.csv order) order_id, order_date, customer_id, store_id, channel, product_id, unit_price, quantity, discount, revenue

orders has no region, product or category columns. Get them with a JOIN to stores and products. There are two indexes: idx_orders_date on order_date and idx_orders_customer on customer_id. Dates are TEXT in ISO format, so strftime and string comparison work.

Saved HTTP responses (https://api.example.com/v1/...) for the APIs module.

  • products_page_1.json, products_page_2.json, products_page_3.json: each has the keys page, per_page (10), total (30), total_pages (3), next and data. next is the URL of the next page (https://api.example.com/v1/products?page=2&per_page=10), or null on page 3. Each item in data has id (the product_id), name, category, price (with amount and currency “USD”), in_stock, stock, rating (with average, the mean review rating to 1 decimal, and count, the number of reviews), launch_date and url. P006 and P019 are out of stock (stock 0).
  • weather_forecast.json: location (name Chicago, country, latitude, longitude, timezone), generated_at, units (temperature “°C”, precipitation “mm”, wind_speed “km/h”), current (time, temperature_c, condition), daily (2 days with date, min_c, max_c) and hourly (48 records from 2024-05-01T00:00 to 2024-05-02T23:00). Each hourly record has time, temperature_c, feels_like_c, humidity_pct, precipitation_mm, precipitation_probability, wind (with speed_kmh and direction_deg) and condition (with code and text). Rain is likely from 2024-05-02T00:00 to 09:00.
  • error_429.json: a flat rate-limit body with status 429, error “rate_limit_exceeded”, message, retry_after 30 (seconds), limit 60, remaining 0, reset_at and request_id.
  • users.json: a bare JSON list (no wrapper) of 10 users. Each has id (1..10), name, username, email (@example.org), active (1 user is inactive), roles (user 1 is admin), address (with city, zipcode and geo, which holds lat and lng, the city’s real coordinates), company (with name and department) and created_at.
  • catalog.html: a static catalog page for a fictional shop (“Maple & Finch Market”). It has a <table id="products" class="price-table"> with 12 rows (P001..P012). Each row has a data-id attribute, a price in <td class="price"> such as $1,299.00, and stock text. It also has 12 cards, <article class="product-card" data-product-id="...">. Each card has h2.product-name > a[href] (for example /products/p001-wireless-earbuds), p.category, span.price, span.rating[data-rating] with star characters, span.reviews ((N reviews)) and p.stock with class in or out. Three cards (P002, P006, P010) also have an old price in span.price-old. The page includes HTML entities (&amp;, &#x27;, &raquo;, &copy;) and a rel="next" pagination link.

The scores use scikit-learn 1.9.1, pandas 3.1.1, numpy 2.5.4 and statsmodels 0.15.0. The classification and regression pipelines look like this:

pre = ColumnTransformer(
[
("cat", OneHotEncoder(handle_unknown="ignore"), cat_cols),
(
"num",
make_pipeline(SimpleImputer(strategy="median"), StandardScaler()),
num_cols,
),
]
)
model = make_pipeline(pre, LogisticRegression(max_iter=1000)) # or LinearRegression()

Gradient boosting uses HistGradientBoostingClassifier or HistGradientBoostingRegressor with random_state=42 and categorical_features="from_dtype" on the raw columns. The text columns are cast to category, and NaN stays as it is. If a lesson reports other numbers, the lesson computes them itself.