A take-home, start to finish
One made-up data take-home, worked from the brief to the write-up in Hex, with every line of SQL and Python explained and the real output under each cell.
New to SQL? Start with SQL from zero. New to Python? Python for data, from zero. Then come back.
How much do you need to know?
Less than you fear. Most data take-homes for graduate and junior roles use about 15 SQL ideas, 15 pandas ideas and a little JSON. What separates good submissions is the checking and the write-up, not clever code.
SQL
about 15 ideas
- SELECT, FROM, AS pick columns, rename them learn
- WHERE keep rows; AND, OR, BETWEEN, IN learn
- NULL IS NULL; COUNT(col) skips nulls; COALESCE learn
- ORDER BY, LIMIT sort and peek learn
- DISTINCT and COUNT(DISTINCT x) to spot duplicates learn
- COUNT, SUM, AVG, MIN, MAX the five summaries learn
- GROUP BY one row per group learn
- HAVING filter groups after counting learn
- CASE WHEN label rows; count a condition learn
- JOIN, LEFT JOIN and the LEFT JOIN traps (see cell 6) learn
- Grain say what one row of the result stands for learn
- Dates YEAR, DATE_TRUNC, days between two dates learn
- WITH (CTEs) named steps instead of one giant query learn
- Window functions ROW_NUMBER, LAG, SUM() OVER, PARTITION BY learn
- MEDIAN and percentiles, which differ by database learn
pandas and Python
about 15 ideas
- Lists and dicts the shapes JSON arrives in learn
- import, pd.read_csv load a file; parse_dates learn
- shape, head, dtypes first look at any table learn
- df["col"] one column; df[["a", "b"]] for several learn
- Filtering df[df["x"] > 5], .isin(), ~ for "not" learn
- sort_values sort by one or more columns learn
- New columns maths on columns; True/False flags learn
- isna, duplicated find gaps and repeats; drop_duplicates learn
- groupby + agg count, mean, median per group learn
- transform a group's value on every row learn
- pivot_table groups down the side and across the top learn
- merge how="left", then check for NaN learn
- Dates .dt.year, subtracting dates learn
- pct_change, shift change on the period before learn
- Error messages read the last line first learn
JSON
6 ideas
- { } and [ ] objects become dicts, arrays become lists learn
- json.load read a file into lists and dicts learn
- raw[0]["comp"] step down into nested fields learn
- pd.json_normalize flatten nesting into comp.base columns learn
- explode one row per item in a list (perks) learn
- UNNEST, struct.field the same jobs in DuckDB SQL learn
Charts and write-up
5 habits
- Bar or line bars to compare groups, lines for time learn
- Title = finding say what the chart shows, in words
- One highlight one strong colour, everything else grey
- How sure sample size and a rough margin of error
- Three findings then caveats, then next steps
The case
Made up for practice. The company, the employers and every number are invented.
Take-home brief: Data Analyst
Thanks for taking this on. Our employer clients keep asking one thing: if we pay under the market, do we lose candidates?
Attached are job offers from 42 employers for 2024 and 2025 (offers.csv, companies.csv), and the first export from our new system, Q1 2026 (offers_2026.json). Please tell us:
- Are offers below the going rate turned down more often? By how much?
- Which employers look most exposed?
- Does the early 2026 data say the same?
Use SQL and Python in Hex. Send us a link to a published app. Please spend no more than three hours.
1. Read it twice: the one-sentence question
Writing it down does two things. It stops you drifting into interesting side questions. And it shows you the words that need defining: "going rate", "below", "declined".
2. Clarifying questions, and what to assume
Ask these if you can. If you cannot, write the assumption at the top of your notebook and carry on.
| Ask | If no answer, assume |
|---|---|
| What is "the going rate"? | The median base salary for the same job family, level and year, across all 42 employers. |
| Base salary, or base plus equity? | Base. Only some offers include equity. Adding it is a next step. |
| How far under counts as "below"? | More than 5% under (a pay ratio under 0.95). Within 5% either side is "at". |
| What about broken rows? | Keep one copy of each offer. Drop salaries under €20,000 or over €400,000, and offers with no level. Say so in the write-up. |
| Is 2026 comparable? | Compare it with the 2025 going rate, since 2026 has too few offers for its own. |
3. The plan
Each step is one cell. Each cell makes a named table (right) that the next cell uses.
4. Set up in Hex
Hex is a browser notebook that mixes SQL, Python and text cells, then publishes the result as an app. Menu names change, so these steps describe what to look for. Checked against Hex's docs in December 2026.
| Do | How |
|---|---|
| Start a project | A new project opens as a notebook: a column of cells. |
| Upload the files | Use the Files sidebar to upload the two CSVs and the JSON. Python cells can then read them by file name. If that fails, copy the path Hex shows for the file. |
| Add a Python cell | For loading files (cell 1), checks and charts. Common packages such as pandas are normally ready to import. If an import fails, Hex’s docs show how to install a package. |
| Add a SQL cell on dataframes | Choose dataframes as the cell's source, not a database. Hex calls this dataframe SQL and runs it with DuckDB, so the SQL here works as written. FROM offers means the offers dataframe. |
| Name each result | A SQL cell returns its result as a pandas dataframe with a name, which later SQL and Python cells use like a table. Name them as on this page: checks, clean, rated... |
| Charts | Either matplotlib in a Python cell (cells 9 and 10), or a no-code chart cell pointed at a dataframe such as by_band. |
| Write in text cells | Put the question and assumptions at the top, a line under each result, and the write-up at the end. Text cells can show a Python value with {{ name }}. |
| Publish the app | In the App builder, pick and arrange the cells to show: text, key tables and charts, not every line of code. Then Publish and share the link. |
No Hex? Every cell here also runs on your own computer: pip install duckdb pandas matplotlib, then run each SQL cell from Python with duckdb.sql(query).df(). That is how the outputs below were made. The practice guide's setup shows the steps, plus Google Colab.
The cells, every line explained
For each cell: why it exists and what to expect, then the code with each line explained beside it, then what it really printed. Line numbers match the plain code under each listing.
Load and check the data (cells 1-2)
offers, companiesThinking out loud. Get the files in and look at them before asking any questions of them. Expect 689 offers and 42 employers, if the brief is right, and dates read as dates.
import pandas as pd pd. Hex comes with it installed. The blank line is just spacing.offers = pd.read_csv("offers.csv", parse_dates=["offered_at", "accepted_at"])offers. parse_dates turns those two columns into real dates, so you can compare them later. Without it they stay as text.companies = pd.read_csv("companies.csv") print(offers.shape, companies.shape)shape is (rows, columns). First check: does it match the brief?print(offers.dtypes)int64) and dates should be datetime. A salary read as text is a red flag.Plain code to copy
import pandas as pd
offers = pd.read_csv("offers.csv", parse_dates=["offered_at", "accepted_at"])
companies = pd.read_csv("companies.csv")
print(offers.shape, companies.shape)
print(offers.dtypes)Output -- older pandas prints object where this says str
(689, 9) (42, 5)
offer_id str
company_id str
job_family str
level str
base_salary int64
equity_value int64
offered_at datetime64[us]
accepted_at datetime64[us]
status str
dtype: object
checksThinking out loud. Before any analysis, prove the data is what it claims. One query, one row, every check you would be embarrassed to skip: duplicates, gaps, impossible values.
SELECTGROUP BY, the whole table squashes into one row of results. COUNT(*) AS n_rows,COUNT(*) counts every row. COUNT(DISTINCT offer_id) AS n_offers, COUNT(*) - COUNT(level) AS no_level,COUNT(level) skips empty (NULL) values, so the difference is the number of missing levels. COUNT(CASE WHEN status = 'declined' THEN 1 END) AS declined,CASE WHEN gives 1 for a declined offer and NULL otherwise. COUNT counts the 1s. A handy way to count a condition. COUNT(*) - COUNT(accepted_at) AS no_accept_date, MIN(base_salary) AS min_base, MAX(base_salary) AS max_base, COUNT(CASE WHEN accepted_at < offered_at THEN 1 END) AS accepted_too_earlyFROM offersoffers here is the dataframe from cell 1, not a database table.Plain code to copy
SELECT
COUNT(*) AS n_rows,
COUNT(DISTINCT offer_id) AS n_offers,
COUNT(*) - COUNT(level) AS no_level,
COUNT(CASE WHEN status = 'declined' THEN 1 END) AS declined,
COUNT(*) - COUNT(accepted_at) AS no_accept_date,
MIN(base_salary) AS min_base,
MAX(base_salary) AS max_base,
COUNT(CASE WHEN accepted_at < offered_at THEN 1 END) AS accepted_too_early
FROM offersOutput
checks: 1 row
n_rows n_offers no_level declined no_accept_date min_base max_base accepted_too_early
689 686 5 147 147 15 1500000 0
The SQL cells (3-6)
cleanThinking out loud. Fix what the checks found, in one place, so every later step uses the same clean table. Expect 686 - 2 - 5 = 679 rows, if no row has two problems.
WITH numbered AS (numbered. Named steps keep long queries readable. SELECT *,*) from each row... ROW_NUMBER() OVER (PARTITION BY offer_id ORDER BY offered_at) AS copy_noPARTITION BY offer_id restarts the count for every offer, so the first copy gets 1 and a duplicate gets 2. FROM offers)SELECT offer_id, company_id, job_family, level, base_salary, status, YEAR(offered_at) AS offer_yearFROM numberedWHERE copy_no = 1 AND base_salary BETWEEN 20000 AND 400000 AND level IS NOT NULLORDER BY offer_idPlain code to copy
WITH numbered AS (
SELECT
*,
ROW_NUMBER() OVER (PARTITION BY offer_id ORDER BY offered_at) AS copy_no
FROM offers
)
SELECT
offer_id, company_id, job_family, level, base_salary, status,
YEAR(offered_at) AS offer_year
FROM numbered
WHERE copy_no = 1
AND base_salary BETWEEN 20000 AND 400000
AND level IS NOT NULL
ORDER BY offer_idOutput -- first rows shown; 679 in all, as expected
clean: 679 rows
offer_id company_id job_family level base_salary status offer_year
O0001 C006 Data Analyst Lead 96500 accepted 2024
O0002 C033 Data Scientist Senior 108500 declined 2024
O0003 C030 Designer Lead 81000 accepted 2024
O0004 C027 Software Engineer Mid 74000 accepted 2024
O0005 C002 Data Analyst Mid 55000 accepted 2024
...
ratedThinking out loud. The core idea. An offer is only low or high compared with similar offers. So give each offer a going rate: the median base salary for the same job family, level and year. Then divide.
WITH with_rate AS (with_rate. SELECT *,clean... MEDIAN(base_salary) OVER ( PARTITION BY job_family, level, offer_yearOVER (PARTITION BY ...) makes this a window function: it works out the median per group but keeps every row, unlike GROUP BY, which would squash them. ) AS going_rategoing_rate. FROM clean)SELECT *, ROUND(base_salary / going_rate, 3) AS pay_ratio, CASECASE checks each WHEN in order and stops at the first that is true. WHEN base_salary / going_rate < 0.95 THEN 'below'below. WHEN base_salary / going_rate <= 1.05 THEN 'at'at. Rows already labelled below never get here. ELSE 'above'above. END AS pay_bandCASE and name the column.FROM with_rateORDER BY offer_idPlain code to copy
WITH with_rate AS (
SELECT
*,
MEDIAN(base_salary) OVER (
PARTITION BY job_family, level, offer_year
) AS going_rate
FROM clean
)
SELECT
*,
ROUND(base_salary / going_rate, 3) AS pay_ratio,
CASE
WHEN base_salary / going_rate < 0.95 THEN 'below'
WHEN base_salary / going_rate <= 1.05 THEN 'at'
ELSE 'above'
END AS pay_band
FROM with_rate
ORDER BY offer_idOther databases. MEDIAN(...) OVER works in DuckDB (so in Hex dataframe SQL) and Snowflake. PostgreSQL has no median window: work out the medians with PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY base_salary) and GROUP BY, then join them back. YEAR(d) is EXTRACT(YEAR FROM d) almost everywhere.
Output -- first rows shown; still 679
rated: 679 rows
offer_id company_id job_family level base_salary status offer_year going_rate pay_ratio pay_band
O0001 C006 Data Analyst Lead 96500 accepted 2024 92000.0 1.049 at
O0002 C033 Data Scientist Senior 108500 declined 2024 101500.0 1.069 above
O0003 C030 Designer Lead 81000 accepted 2024 97000.0 0.835 below
O0004 C027 Software Engineer Mid 74000 accepted 2024 83750.0 0.884 below
O0005 C002 Data Analyst Mid 55000 accepted 2024 59000.0 0.932 below
...
by_bandThinking out loud. Now the answer to question 1. One row per band: how many offers, how many declined, and the rate. If pay does not matter, the three rates should be about the same.
SELECT pay_band,GROUP BY below, the result has one row per band. That is the grain. COUNT(*) AS offers, COUNT(CASE WHEN status = 'declined' THEN 1 END) AS declined, ROUND(100.0 * AVG(CASE WHEN status = 'declined' THEN 1 ELSE 0 END), 1) AS decline_pctCASE gives 1 or 0, so its average is the share declined. 100.0 (not 100) keeps the maths in decimals; some databases throw away the fraction when you divide whole numbers.FROM ratedGROUP BY pay_bandORDER BY MIN(pay_ratio)Plain code to copy
SELECT
pay_band,
COUNT(*) AS offers,
COUNT(CASE WHEN status = 'declined' THEN 1 END) AS declined,
ROUND(100.0 * AVG(CASE WHEN status = 'declined' THEN 1 ELSE 0 END), 1) AS decline_pct
FROM rated
GROUP BY pay_band
ORDER BY MIN(pay_ratio)Output
by_band: 3 rows
pay_band offers declined decline_pct
below 210 65 31.0
at 274 49 17.9
above 195 29 14.9
by_employerThinking out loud. Question 2: which employers look most exposed? Start from the employers table so none is silently missing, then summarise each one's offers. Expect some employers with very few offers; those rates mean little.
SELECT c.name,c. means "from the table nicknamed c". COUNT(r.offer_id) AS offers,COUNT(r.offer_id), not COUNT(*). An employer with no offers still gets one row from a LEFT JOIN, full of NULLs. COUNT(*) would count that empty row as 1 offer. This counts 0. ROUND(MEDIAN(r.pay_ratio), 2) AS pay_ratio, ROUND(100.0 * AVG(CASE WHEN r.status = 'declined' THEN 1 ELSE 0 END), 1) AS decline_pctFROM companies AS cc.LEFT JOIN rated AS r ON r.company_id = c.company_idLEFT JOIN keeps employers with no match. ON says which columns must agree.GROUP BY c.nameHAVING COUNT(r.offer_id) >= 10HAVING filters after the counting; WHERE cannot, because it runs before.ORDER BY pay_ratioPlain code to copy
SELECT
c.name,
COUNT(r.offer_id) AS offers,
ROUND(MEDIAN(r.pay_ratio), 2) AS pay_ratio,
ROUND(100.0 * AVG(CASE WHEN r.status = 'declined' THEN 1 ELSE 0 END), 1) AS decline_pct
FROM companies AS c
LEFT JOIN rated AS r
ON r.company_id = c.company_id
GROUP BY c.name
HAVING COUNT(r.offer_id) >= 10
ORDER BY pay_ratioOutput
by_employer: 27 rows
name offers pay_ratio decline_pct
Rookery Learning 36 0.86 36.1
Cobbler Lane Shops 13 0.87 53.8
Tumbleweed Mobility 28 0.89 17.9
Brackenwood Software 12 0.91 25.0
Riverlight Energy 14 0.92 28.6
Starling Row Insurance 31 0.93 22.6
Gorsehill Telecom 16 0.94 43.8
Sedgewick Security 10 0.95 20.0
Umberfield Grocers 30 0.95 23.3
Pipistrelle Studios 11 0.95 9.1
Mossgate Retail 11 0.95 18.2
Quayside Cloud 13 0.96 38.5
Kilnworth Energy 28 0.96 25.0
Northgale Airlines 14 0.98 28.6
Millrace Data 14 0.98 14.3
Thimble Health 37 1.00 18.9
Pebblebrook Insurance 26 1.00 7.7
Oakum Freight 36 1.01 25.0
Copperline Logistics 41 1.01 22.0
Quernstone Property 11 1.02 36.4
Ashgrove Analytics 16 1.04 0.0
Saltmarsh Media 14 1.05 21.4
Yarrowby Payroll 13 1.06 38.5
Tallowmere Pharma 32 1.07 9.4
Vellum Publishing 37 1.07 10.8
Fernhollow Fashion 31 1.08 9.7
Juniper Ledger 20 1.16 10.0
Thinking out loud. Worth seeing once: the same query with COUNT(*) and no HAVING. This is the LEFT JOIN trap that catches people in take-homes.
SELECT c.name, COUNT(*) AS offers,COUNT(*) counts rows, including the empty row a LEFT JOIN makes for an employer with no offers. ROUND(100.0 * AVG(CASE WHEN r.status = 'declined' THEN 1 ELSE 0 END), 1) AS decline_pctstatus is NULL, so CASE falls to ELSE 0: a 0% decline rate made from nothing.FROM companies AS cLEFT JOIN rated AS r ON r.company_id = c.company_idGROUP BY c.nameORDER BY offersLIMIT 3Plain code to copy
SELECT
c.name,
COUNT(*) AS offers,
ROUND(100.0 * AVG(CASE WHEN r.status = 'declined' THEN 1 ELSE 0 END), 1) AS decline_pct
FROM companies AS c
LEFT JOIN rated AS r
ON r.company_id = c.company_id
GROUP BY c.name
ORDER BY offers
LIMIT 3Output
trap: 3 rows
name offers decline_pct
Lanternfly Ceramics 1 0.0
Kestrel Minds 3 33.3
Brindle Robotics 4 25.0
The Python cells: sanity checks and JSON (7-8)
Thinking out loud. A finding is only worth sending once you have tried to break it. Four checks: nothing lost along the way, the gap is bigger than chance, it holds in each year, and it is not just the five well-paid AI labs.
rated["declined"] = rated["status"] == "declined" # 1. Nothing lost between steps?print("clean:", len(clean), "| rated:", len(rated), "| in bands:", by_band["offers"].sum()) # 2. Is the gap bigger than the noise?p = by_band["decline_pct"] / 100n = by_band["offers"]p is each band's decline rate as a fraction; n is its number of offers. These are whole columns, so the maths runs on all three bands at once.by_band["margin_pct"] = (196 * (p * (1 - p) / n) ** 0.5).round(1)print(by_band[["pay_band", "offers", "decline_pct", "margin_pct"]]) # 3. Does it hold in both years?print(rated.pivot_table(index="offer_year", columns="pay_band", values="declined", aggfunc="mean").round(3)) pivot_table puts years down the side, bands across the top, and the average of declined in each box. The brackets on two lines are one statement; Python lets it run on.# 4. Do the five AI labs drive it? Rebuild the going rate without them.labs = companies.loc[companies["industry"] == "AI lab", "company_id"]AI lab. .loc[rows, column] picks rows and a column in one go.no_labs = clean[~clean["company_id"].isin(labs)].copy()~ means "not". .copy() makes a separate table, so the next lines do not change clean.no_labs["going_rate"] = (no_labs.groupby(["job_family", "level", "offer_year"]) ["base_salary"].transform("median"))transform("median") works out each group's median and puts it on every row of the group, like the window function in cell 4.no_labs["below"] = no_labs["base_salary"] / no_labs["going_rate"] < 0.95no_labs["declined"] = no_labs["status"] == "declined"print(no_labs.groupby("below")["declined"].agg(["count", "mean"]).round(3))Plain code to copy
rated["declined"] = rated["status"] == "declined"
# 1. Nothing lost between steps?
print("clean:", len(clean), "| rated:", len(rated), "| in bands:", by_band["offers"].sum())
# 2. Is the gap bigger than the noise?
p = by_band["decline_pct"] / 100
n = by_band["offers"]
by_band["margin_pct"] = (196 * (p * (1 - p) / n) ** 0.5).round(1)
print(by_band[["pay_band", "offers", "decline_pct", "margin_pct"]])
# 3. Does it hold in both years?
print(rated.pivot_table(index="offer_year", columns="pay_band",
values="declined", aggfunc="mean").round(3))
# 4. Do the five AI labs drive it? Rebuild the going rate without them.
labs = companies.loc[companies["industry"] == "AI lab", "company_id"]
no_labs = clean[~clean["company_id"].isin(labs)].copy()
no_labs["going_rate"] = (no_labs.groupby(["job_family", "level", "offer_year"])
["base_salary"].transform("median"))
no_labs["below"] = no_labs["base_salary"] / no_labs["going_rate"] < 0.95
no_labs["declined"] = no_labs["status"] == "declined"
print(no_labs.groupby("below")["declined"].agg(["count", "mean"]).round(3))Output
clean: 679 | rated: 679 | in bands: 679
pay_band offers decline_pct margin_pct
0 below 210 31.0 6.3
1 at 274 17.9 4.5
2 above 195 14.9 5.0
pay_band above at below
offer_year
2024 0.154 0.227 0.303
2025 0.144 0.137 0.315
count mean
below
False 462 0.173
True 193 0.321
newThinking out loud. Question 3: does early 2026 agree? The new system exports nested JSON, so flatten it first. There are no 2026 going rates yet, so compare against 2025's. Expect a small sample: 60 offers.
import json json is built into Python; nothing to install.with open("offers_2026.json") as f: raw = json.load(f) with closes the file when done.print(len(raw), "offers. The first one's comp:", raw[0]["comp"]) comp looks like.new = pd.json_normalize(raw)comp.base, company.id. The perks list stays as a list in one column.print(new.columns.tolist()) rate_2025 = (clean[clean["offer_year"] == 2025] .groupby(["job_family", "level"], as_index=False)["base_salary"]as_index=False keeps the group names as normal columns... .median() .rename(columns={"base_salary": "going_rate"})) new = new.merge(rate_2025, on=["job_family", "level"], how="left")how="left" keeps every 2026 offer even if no rate matches.print("Offers with no 2025 going rate:", new["going_rate"].isna().sum()) new["below"] = new["comp.base"] / new["going_rate"] < 0.95comp.base: the flattened name.new["declined"] = new["status"] == "declined"print(new.groupby("below")["declined"].agg(["count", "mean"]).round(3))Plain code to copy
import json
with open("offers_2026.json") as f:
raw = json.load(f)
print(len(raw), "offers. The first one's comp:", raw[0]["comp"])
new = pd.json_normalize(raw)
print(new.columns.tolist())
rate_2025 = (clean[clean["offer_year"] == 2025]
.groupby(["job_family", "level"], as_index=False)["base_salary"]
.median()
.rename(columns={"base_salary": "going_rate"}))
new = new.merge(rate_2025, on=["job_family", "level"], how="left")
print("Offers with no 2025 going rate:", new["going_rate"].isna().sum())
new["below"] = new["comp.base"] / new["going_rate"] < 0.95
new["declined"] = new["status"] == "declined"
print(new.groupby("below")["declined"].agg(["count", "mean"]).round(3))Output
60 offers. The first one's comp: {'base': 137000, 'equity': 26000, 'bonus': 7000}
['offer_id', 'job_family', 'level', 'status', 'offered_at', 'perks', 'company.id', 'company.name', 'company.city', 'comp.base', 'comp.equity', 'comp.bonus']
Offers with no 2025 going rate: 0
count mean
below
False 45 0.133
True 15 0.067
The charts (9-10)
Thinking out loud. One chart for the main finding. Three bars, the one that matters in navy, the rest grey, and a title that says the finding in words. (In Hex, a no-code chart cell can draw the same bars from by_band.)
import matplotlib.pyplot as plt colours = ["#0a4d8c" if b == "below" else "#b9b5aa" for b in by_band["pay_band"]]below, grey for the others. This is a list comprehension: a short loop that builds a list.labels = ["Below the going rate", "At the going rate", "Above the going rate"] by_band's rows (below, at, above), which cell 5's sort guarantees.fig, ax = plt.subplots(figsize=(8, 3.6), facecolor="#fbfaf6")fig is the whole picture; ax is the plotting area.ax.set_facecolor("#fbfaf6")ax.barh(labels, by_band["decline_pct"], color=colours)ax.invert_yaxis()for y, pct in enumerate(by_band["decline_pct"]): ax.text(pct + 0.6, y, f"{pct:.0f}%", va="center", fontsize=12) enumerate gives the position (0, 1, 2) and the value; :.0f rounds to a whole number.ax.set_title("Nearly 1 in 3 offers below the going rate was turned down", loc="left", fontsize=14, fontweight="bold")loc="left" lines it up with the chart's left edge.ax.set_xlabel("Share of offers declined, 2024-25 (made-up data)")ax.set_xticks([])ax.spines[["top", "right", "bottom"]].set_visible(False)ax.tick_params(left=False)plt.savefig("chart_bands.png", dpi=150, bbox_inches="tight")dpi=150 keeps it sharp.plt.show()Plain code to copy
import matplotlib.pyplot as plt
colours = ["#0a4d8c" if b == "below" else "#b9b5aa" for b in by_band["pay_band"]]
labels = ["Below the going rate", "At the going rate", "Above the going rate"]
fig, ax = plt.subplots(figsize=(8, 3.6), facecolor="#fbfaf6")
ax.set_facecolor("#fbfaf6")
ax.barh(labels, by_band["decline_pct"], color=colours)
ax.invert_yaxis()
for y, pct in enumerate(by_band["decline_pct"]):
ax.text(pct + 0.6, y, f"{pct:.0f}%", va="center", fontsize=12)
ax.set_title("Nearly 1 in 3 offers below the going rate was turned down",
loc="left", fontsize=14, fontweight="bold")
ax.set_xlabel("Share of offers declined, 2024-25 (made-up data)")
ax.set_xticks([])
ax.spines[["top", "right", "bottom"]].set_visible(False)
ax.tick_params(left=False)
plt.savefig("chart_bands.png", dpi=150, bbox_inches="tight")
plt.show()
Thinking out loud. A second view at employer level: each dot is an employer with 10+ offers. If paying less loses candidates, the dots should drift down from left to right.
under = by_employer["pay_ratio"] < 0.95 fig, ax = plt.subplots(figsize=(8, 4.6), facecolor="#fbfaf6")ax.set_facecolor("#fbfaf6")ax.scatter(by_employer["pay_ratio"], by_employer["decline_pct"], s=by_employer["offers"] * 4, color=["#0a4d8c" if u else "#b9b5aa" for u in under])s= sizes each dot by its number of offers, so tiny samples look tiny. Navy for under-paying employers.ax.axvline(1, color="#5e5e5e", linewidth=0.8, linestyle=":")ax.text(1.005, 52, "going rate", color="#5e5e5e", fontsize=10) ax.set_title("Employers paying under the going rate lost more candidates", loc="left", fontsize=14, fontweight="bold")ax.set_xlabel("Employer's median offer as a share of the going rate (1 = market)")ax.set_ylabel("Offers declined (%)")ax.spines[["top", "right"]].set_visible(False)plt.savefig("chart_employers.png", dpi=150, bbox_inches="tight")plt.show() print(under.sum(), "employers pay under 0.95. Median decline rate:", by_employer.loc[under, "decline_pct"].median(), "% vs", by_employer.loc[~under, "decline_pct"].median(), "% for the rest")Plain code to copy
under = by_employer["pay_ratio"] < 0.95
fig, ax = plt.subplots(figsize=(8, 4.6), facecolor="#fbfaf6")
ax.set_facecolor("#fbfaf6")
ax.scatter(by_employer["pay_ratio"], by_employer["decline_pct"],
s=by_employer["offers"] * 4, color=["#0a4d8c" if u else "#b9b5aa" for u in under])
ax.axvline(1, color="#5e5e5e", linewidth=0.8, linestyle=":")
ax.text(1.005, 52, "going rate", color="#5e5e5e", fontsize=10)
ax.set_title("Employers paying under the going rate lost more candidates",
loc="left", fontsize=14, fontweight="bold")
ax.set_xlabel("Employer's median offer as a share of the going rate (1 = market)")
ax.set_ylabel("Offers declined (%)")
ax.spines[["top", "right"]].set_visible(False)
plt.savefig("chart_employers.png", dpi=150, bbox_inches="tight")
plt.show()
print(under.sum(), "employers pay under 0.95. Median decline rate:",
by_employer.loc[under, "decline_pct"].median(), "% vs",
by_employer.loc[~under, "decline_pct"].median(), "% for the rest")
Output
7 employers pay under 0.95. Median decline rate: 28.6 % vs 19.45 % for the rest
The write-up
This is what goes at the top of the published app, above the two charts. Short enough to read in a minute.
Findings
- Offers below the going rate were declined almost twice as often. 31% of them (65 of 210), against 18% at the going rate and 15% above it, across 679 offers in 2024-25. The gap is about twice the margin of error, and holds in both years.
- It is not the AI labs. With the five high-paying labs taken out, the gap is 32% against 17%.
- Seven employers pay more than 5% under the going rate, and their typical decline rate is 29%, against 19% for the other 20. Cobbler Lane Shops (54% declined) and Gorsehill Telecom (44%) look most exposed; Rookery Learning pays least and has the most offers at risk (36).
Too early to tell
Q1 2026 has only 15 offers below the going rate, and 1 was declined. That is too few to confirm or contradict the pattern. Check again after Q2.
Caveats
- This shows a link, not a cause. Employers that pay less may also differ in brand, location or speed.
- The going rate comes from these 42 employers, not the whole market. Base salary only; equity and bonus left out.
- Removed: 3 duplicated rows, 2 impossible salaries, 5 offers with no level.
Next steps
- Repeat with total pay (base plus equity).
- Control for job family, level and city together, for example with a simple regression.
- Rerun the 2026 check once Q2 is in.
What the grader is looking for
| They check | Weak | Strong |
|---|---|---|
| The question | Starts coding straight away | One-sentence question and assumptions at the top |
| Data checks | None, or hidden | Duplicates, gaps and impossible values found, and what was done about each |
| SQL | One giant query | Small named steps, each with a clear grain |
| Correctness | Joins that drop or invent rows | Row counts tie out between steps; LEFT JOIN traps handled |
| Judgement | Calls 15 offers a trend | Margins of error, other explanations, says what the data cannot tell |
| Communication | A code dump | Finding-first charts, three findings, caveats, next steps; code hidden in the app |
Common mistakes
COUNT(*) after a LEFT JOIN. It counts the empty row as 1 (cell 6b).Practice next
Eight more take-home style tasks on the same data, each with a worked answer:
- Can we trust this data?
- Flatten a JSON export
- A pay ladder by level
- Where do candidates say no?
- A quarterly pay tracker
- The fill rate that looked wrong
- Fix a published number
- Is the pay jump a story?
Then test yourself out loud with Data interview questions.
All data on this page is made up for practice. Every output was produced by running the code shown, with DuckDB 2.0.1, pandas 3.1.2 and matplotlib 3.11.2.