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
What you can skip for now: classes and object-oriented Python, decorators, machine-learning models, regular expressions beyond the basics, recursive SQL, indexes and database design, and matplotlib styling past the basics. If a take-home needs one of these, the brief will usually say so.

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:

  1. Are offers below the going rate turned down more often? By how much?
  2. Which employers look most exposed?
  3. 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
Are offers paying below the going rate for the same job, level and year declined more often than offers at or above it -- and by how much?

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.

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

The plan: nine steps from brief to write-up. Each SQL or Python cell makes a named table the next step uses.Read, ask, planthe questionPYLoad the filesoffers, companiesSQLCheck the datachecksSQLOne clean row per offercleanSQLRate each offerratedSQLDecline rate by bandby_bandSQLSame, by employerby_employerPYSanity checks + 2026 JSONnewPYCharts and write-upthe app
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.

DoHow
Start a projectA new project opens as a notebook: a column of cells.
Upload the filesUse 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 cellFor 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 dataframesChoose 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 resultA 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...
ChartsEither 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 cellsPut 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 appIn 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)
Python cell 1makes offers, companies

Thinking 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
Load pandas, the table library, under the short name pd. Hex comes with it installed. The blank line is just spacing.
offers = pd.read_csv("offers.csv", parse_dates=["offered_at", "accepted_at"])
Read the CSV into a dataframe (a table in Python) called 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")
Same for the employers file. No dates in this one.
print(offers.shape, companies.shape)
shape is (rows, columns). First check: does it match the brief?
print(offers.dtypes)
The type of every column. Salaries should be numbers (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
SQL cell 2makes checks

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

SELECT
Start the query. With no GROUP 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,
Counts each offer ID once. If this is smaller than the row count, some offers appear twice.
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,
Missing acceptance dates, by the same trick as line 4.
MIN(base_salary) AS min_base, MAX(base_salary) AS max_base,
The lowest and highest salary. The fastest way to catch a typo.
COUNT(CASE WHEN accepted_at < offered_at THEN 1 END) AS accepted_too_early
An offer accepted before it was made is impossible. Count them.
FROM offers
In Hex, offers 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 offers

Output

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
Read it. 689 rows but 686 offers: 3 duplicates. €15 and €1,500,000 cannot be real salaries. 5 offers have no level. The 147 missing acceptance dates match the 147 declined offers exactly, so those are expected, not errors. No offer was accepted too early.
The SQL cells (3-6)
SQL cell 3makes clean

Thinking 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 (
Start a named step (a CTE) called numbered. Named steps keep long queries readable.
SELECT *,
Take every column (*) from each row...
ROW_NUMBER() OVER (PARTITION BY offer_id ORDER BY offered_at) AS copy_no
...and number the copies of each offer. PARTITION BY offer_id restarts the count for every offer, so the first copy gets 1 and a duplicate gets 2.
FROM offers)
Close the named step.
SELECT offer_id, company_id, job_family, level, base_salary, status,
The main query. Keep only the columns this case needs. Fewer columns, fewer mistakes.
YEAR(offered_at) AS offer_year
Pull the year out of the offer date. The going rate will be worked out per year, because pay rises over time.
FROM numbered
Read from the named step above.
WHERE copy_no = 1
Keep the first copy of each offer. Duplicates gone.
AND base_salary BETWEEN 20000 AND 400000
Drop the two impossible salaries. Any limits far outside real pay will do; write down the ones you chose.
AND level IS NOT NULL
Drop the 5 offers with no level. You cannot compare them with others at the same level.
ORDER BY offer_id
Sort by offer ID so the output is the same every run.
Plain 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_id

Output -- 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
...
SQL cell 4makes rated

Thinking 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 (
A named step called with_rate.
SELECT *,
Keep every column from clean...
MEDIAN(base_salary) OVER ( PARTITION BY job_family, level, offer_year
...and add the median salary of that offer's group. OVER (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_rate
Call the new column going_rate.
FROM clean)
Read from cell 3's result, and close the step.
SELECT *,
The main query: every column so far...
ROUND(base_salary / going_rate, 3) AS pay_ratio,
...plus the pay ratio. 1.000 means exactly the going rate; 0.900 means 10% under. Rounded to 3 places to keep it readable.
CASE
Start a label. CASE checks each WHEN in order and stops at the first that is true.
WHEN base_salary / going_rate < 0.95 THEN 'below'
More than 5% under the going rate: below.
WHEN base_salary / going_rate <= 1.05 THEN 'at'
Within 5% either side: at. Rows already labelled below never get here.
ELSE 'above'
Anything left is more than 5% over: above.
END AS pay_band
Close the CASE and name the column.
FROM with_rateORDER BY offer_id
Read from the named step; sort for a stable output.
Plain 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_id

Other 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
...
SQL cell 5makes by_band

Thinking 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
Start the query.
pay_band,
The band label. Because of the GROUP BY below, the result has one row per band. That is the grain.
COUNT(*) AS offers,
Offers in the band.
COUNT(CASE WHEN status = 'declined' THEN 1 END) AS declined,
Declined offers in the band, by the trick from cell 2.
ROUND(100.0 * AVG(CASE WHEN status = 'declined' THEN 1 ELSE 0 END), 1) AS decline_pct
The decline rate. The CASE 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 rated
Read from cell 4's result.
GROUP BY pay_band
One group per band.
ORDER BY MIN(pay_ratio)
Sort the bands from lowest-paid to highest-paid by their smallest ratio, so below, at, above come out in a sensible order.
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
Read it. 31% of offers below the going rate were declined, against 18% at it and 15% above it. A clear gap. Now try to break it (cell 7).
SQL cell 6makes by_employer

Thinking 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
Start the query.
c.name,
The employer's 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,
The employer's typical pay ratio. Median, so one odd offer cannot drag it.
ROUND(100.0 * AVG(CASE WHEN r.status = 'declined' THEN 1 ELSE 0 END), 1) AS decline_pct
Decline rate, as in cell 5.
FROM companies AS c
Start from every employer, nicknamed c.
LEFT JOIN rated AS r ON r.company_id = c.company_id
Attach each employer's offers. LEFT JOIN keeps employers with no match. ON says which columns must agree.
GROUP BY c.name
One row per employer. That is the grain.
HAVING COUNT(r.offer_id) >= 10
Keep employers with at least 10 offers. HAVING filters after the counting; WHERE cannot, because it runs before.
ORDER BY pay_ratio
Lowest-paying employers first.
Plain 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_ratio

Output

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
SQL cell 6b

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,
As before.
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_pct
For that empty row, status 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.name
Same join and grouping as cell 6.
ORDER BY offersLIMIT 3
Show the three employers with the fewest offers.
Plain 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 3

Output

trap: 3 rows
               name  offers  decline_pct
Lanternfly Ceramics       1          0.0
      Kestrel Minds       3         33.3
   Brindle Robotics       4         25.0
The trap. Lanternfly Ceramics made no offers at all, yet this says 1 offer and a 0% decline rate -- the best record in the data. In a ranking it would sit at the top. Kestrel Minds is real but has only 3 offers, so one decline swings its rate by 33 points. Cell 6 fixes both.
The Python cells: sanity checks and JSON (7-8)
Python cell 7

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"
Add a True/False column: was this offer declined? The average of True/False is the share that are True.
# 1. Nothing lost between steps?print("clean:", len(clean), "| rated:", len(rated), "| in bands:", by_band["offers"].sum())
Check 1. Every clean offer should reach a band, once. All three numbers should match.
# 2. Is the gap bigger than the noise?
Check 2. A rough margin of error for each rate.
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)
The usual rough 95% margin for a share: 1.96 times the square root of p(1-p)/n. The 196 is 1.96 times 100, to give percentage points.
print(by_band[["pay_band", "offers", "decline_pct", "margin_pct"]])
Print the bands with their margins. Double brackets pick several columns.
# 3. Does it hold in both years?
Check 3. Split by year.
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.
Check 4. In 2025, five new AI labs paid about 1.7 times the going rate. They pull the Data Scientist median up, which could make other employers look "below".
labs = companies.loc[companies["industry"] == "AI lab", "company_id"]
The company IDs whose industry is AI lab. .loc[rows, column] picks rows and a column in one go.
no_labs = clean[~clean["company_id"].isin(labs)].copy()
Every clean offer not from a lab. ~ 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"))
Rebuild the going rate without the labs. 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.95
True when the offer is more than 5% under the new going rate.
no_labs["declined"] = no_labs["status"] == "declined"
The same declined flag as line 1.
print(no_labs.groupby("below")["declined"].agg(["count", "mean"]).round(3))
For below (True) and not below (False): how many offers, and the share declined.
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
Read it. All 679 offers accounted for. The gap (31% vs 18%) is about twice the margins of error (6.3 and 4.5 points), so chance is an unlikely explanation. It holds in 2024 and 2025. Without the AI labs it is 32% vs 17%: the labs are not the reason.
Python cell 8makes new

Thinking 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)
Open the file and turn the JSON into Python: a list of offers, each one a dict (a set of named values). with closes the file when done.
print(len(raw), "offers. The first one's comp:", raw[0]["comp"])
Peek before flattening: how many offers, and what one nested comp looks like.
new = pd.json_normalize(raw)
Flatten. Nested fields become columns with dotted names: comp.base, company.id. The perks list stays as a list in one column.
print(new.columns.tolist())
List the new column names, so you use the right ones.
rate_2025 = (clean[clean["offer_year"] == 2025]
The 2025 going rate per job family and level. Start from 2025 clean offers...
.groupby(["job_family", "level"], as_index=False)["base_salary"]
...group them; as_index=False keeps the group names as normal columns...
.median()
...take the median salary of each group...
.rename(columns={"base_salary": "going_rate"}))
...and rename it, so the join below is easy to read.
new = new.merge(rate_2025, on=["job_family", "level"], how="left")
Attach a going rate to each 2026 offer. how="left" keeps every 2026 offer even if no rate matches.
print("Offers with no 2025 going rate:", new["going_rate"].isna().sum())
So check for gaps. A left join with no match fills NaN (empty), and the next line would quietly drop those offers. Here it is 0.
new["below"] = new["comp.base"] / new["going_rate"] < 0.95
Below the going rate? Note comp.base: the flattened name.
new["declined"] = new["status"] == "declined"
The declined flag again.
print(new.groupby("below")["declined"].agg(["count", "mean"]).round(3))
Offers and decline rate, below versus not below.
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
Read it. In 2026, 1 of 15 offers below the going rate was declined, against 6 of 45 others. That points the other way -- but 15 offers is far too few to say anything. One more decline would move the rate by 7 points. Report it as "too early to tell", not as a reversal.
The charts (9-10)
Python cell 9

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
Load matplotlib's plotting tools under the usual short name.
colours = ["#0a4d8c" if b == "below" else "#b9b5aa" for b in by_band["pay_band"]]
A list of colours, one per bar: navy for 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"]
Readable labels in the same order as by_band's rows (below, at, above), which cell 5's sort guarantees.
fig, ax = plt.subplots(figsize=(8, 3.6), facecolor="#fbfaf6")
Make a blank chart 8 by 3.6 inches on the site's cream background. fig is the whole picture; ax is the plotting area.
ax.set_facecolor("#fbfaf6")
Cream behind the bars too.
ax.barh(labels, by_band["decline_pct"], color=colours)
Horizontal bars: labels down the side, decline rates as lengths.
ax.invert_yaxis()
Put the first row at the top. Horizontal bars start from the bottom otherwise.
for y, pct in enumerate(by_band["decline_pct"]): ax.text(pct + 0.6, y, f"{pct:.0f}%", va="center", fontsize=12)
Write each value at the end of its bar. 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")
The title is the finding, not a description. loc="left" lines it up with the chart's left edge.
ax.set_xlabel("Share of offers declined, 2024-25 (made-up data)")
Say what is being measured, and that the data is made up.
ax.set_xticks([])
No x-axis numbers: the labels on the bars do that job.
ax.spines[["top", "right", "bottom"]].set_visible(False)ax.tick_params(left=False)
Remove the box lines and tick marks. Less ink, same information.
plt.savefig("chart_bands.png", dpi=150, bbox_inches="tight")
Save a PNG for the write-up. dpi=150 keeps it sharp.
plt.show()
Show it under the cell.
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()
Bar chart: 31% of offers below the going rate were declined, against 18% at the going rate and 15% above it.
Python cell 10

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
True for employers whose median offer is more than 5% under the going rate.
fig, ax = plt.subplots(figsize=(8, 4.6), facecolor="#fbfaf6")ax.set_facecolor("#fbfaf6")
A blank chart on cream, as in cell 9.
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])
A scatter: pay ratio across, decline rate up. 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=":")
A dotted line at 1, the going rate.
ax.text(1.005, 52, "going rate", color="#5e5e5e", fontsize=10)
Label that line.
ax.set_title("Employers paying under the going rate lost more candidates", loc="left", fontsize=14, fontweight="bold")
The finding as the title.
ax.set_xlabel("Employer's median offer as a share of the going rate (1 = market)")
Explain the x-axis in plain words.
ax.set_ylabel("Offers declined (%)")
Label the y-axis.
ax.spines[["top", "right"]].set_visible(False)
Drop the top and right box lines.
plt.savefig("chart_employers.png", dpi=150, bbox_inches="tight")plt.show()
Save and 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")
Put a number on what the chart shows: the median decline rate of the two groups of employers.
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")
Scatter of 27 employers: the seven paying under 95% of the going rate, in navy, sit mostly higher, with decline rates from 18% to 54%.

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

  1. 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.
  2. It is not the AI labs. With the five high-paying labs taken out, the gap is 32% against 17%.
  3. 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

Next steps

What the grader is looking for

They checkWeakStrong
The questionStarts coding straight awayOne-sentence question and assumptions at the top
Data checksNone, or hiddenDuplicates, gaps and impossible values found, and what was done about each
SQLOne giant querySmall named steps, each with a clear grain
CorrectnessJoins that drop or invent rowsRow counts tie out between steps; LEFT JOIN traps handled
JudgementCalls 15 offers a trendMargins of error, other explanations, says what the data cannot tell
CommunicationA code dumpFinding-first charts, three findings, caveats, next steps; code hidden in the app

Common mistakes

Comparing across levels. A Junior paid less than a Lead is not underpaid. Compare like with like.
Averaging messy pay. One €1.5m typo moves an average a lot. A median barely notices.
COUNT(*) after a LEFT JOIN. It counts the empty row as 1 (cell 6b).
Skipping the duplicates. A repeated offer counts twice in every rate.
Trusting a left merge. Check for NaN after it, or rows quietly fall out later.
Calling a link a cause. Say "linked to", and name the other explanations.
Small samples. 15 offers cannot make a trend. Say "too early to tell".
Titles that describe. "Decline rate by band" says nothing. Put the finding in the title.

Practice next

Eight more take-home style tasks on the same data, each with a worked answer:

  1. Can we trust this data?
  2. Flatten a JSON export
  3. A pay ladder by level
  4. Where do candidates say no?
  5. A quarterly pay tracker
  6. The fill rate that looked wrong
  7. Fix a published number
  8. 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.

Back to the top