Your salary chart has more observations than your jobs table, and now you've to explain the difference before someone mistakes it for extra hiring.
The suspicious line is probably explode("salaryBands"). It looks like ordinary preparation for a chart. It also gives postings with more disclosed bands more weight.
Exploding salaryBands changes the unit of analysis from postings to disclosed pay bands.
Dataspryva's job-board Actor makes that distinction useful: salary summarises primary base pay, while salaryBands preserves every disclosed band, including location zones, OTE and commission. OTE and commission stay outside the primary base-pay envelope.
Both representations can support valid analysis. They answer different questions.
Where the extra votes come from
Before flattening anything, keep the fetched records intact so you can trace a plotted value back to its posting.
Example board pull: replace the board-token placeholder with the company board you intend to analyse.
import os import re import math import pandas as pd import duckdb from apify_client import ApifyClient run_input = { "mode": "companyJobs", "companies": ["your-board-token"], "onlyWithSalary": False, "maxItems": 500, } client = ApifyClient(os.environ["APIFY_TOKEN"]) run = client.actor( "dataspryva/greenhouse-ats-job-board-lookup-by-company" ).call(run_input=run_input) items = client.dataset(run["defaultDatasetId"]).list_items().items raw = pd.DataFrame(items, dtype=object) Leaving onlyWithSalary false preserves postings without disclosed pay in your fetched population. Otherwise, you can't calculate disclosure coverage from that pull.
The run also has a record cap. Treat its contents as the fetched population unless you've established that the requested boards were fully captured.
Example of the grain change:
posting +-- salary ------------ primary base-pay summary +-- salaryBands +-- disclosed band +-- disclosed band +-- further disclosed bands A band-weighted average gives more influence to a posting with more bands. Grouping by employer afterwards doesn't undo that weighting.
The chart can look perfectly respectable while counting disclosure structure.
Keep the pay fields at their own grain
These are the fields that determine identity, comparability and the denominator. The nullable scalar types below are analysis choices; the object and list structures remain available in the raw columns.
| Field | What you retain and how you type it | Analytical trap |
|---|---|---|
id, companySlug | Posting identifier and board token, stored as pandas string; validate the pair as your posting key | A board token identifies a board, not necessarily your preferred corporate reporting entity |
sourceUrl | Stable posting URL as string | A route back to the advert is not evidence of an employee's actual pay |
salary | Primary pay object, retained raw and flattened separately | Its envelope does not select the geographic band relevant to a particular candidate |
salaryBands | List of disclosed band objects, retained raw before expansion | Each expanded object becomes another observation |
min, max | Endpoints normalised to nullable Float64 | A midpoint requires usable, ordered endpoints |
currency, period | Nullable strings, preserving supplied values | Numeric similarity does not make different currencies or pay periods comparable |
label | Band label as nullable string | Free text is not a ready-made geographic classification |
kind | Band compensation category as nullable string | An unlabelled band cannot safely be assigned to base pay |
range | Primary range representation, preserved raw; retain text separately when present | A display representation is not an additional salary observation |
source | Supplied source marker as nullable string | A provenance marker is not a confidence score |
Empty fields are omitted. For pay, omission can reflect an employer choosing not to disclose a range; it doesn't mean zero compensation.
Retain key presence separately from parsed usability. Otherwise, a malformed value and an undisclosed value become indistinguishable as soon as both turn into NA.
Type endpoints without inventing pay
This parser accepts numeric values, plain decimal strings and comma-grouped numeric strings. Other formats remain missing in the typed columns, with their original values still available for inspection.
def endpoint(value): if isinstance(value, (int, float)) and not isinstance(value, bool): number = float(value) return number if math.isfinite(number) else pd.NA if isinstance(value, str): text = value.strip() pattern = r"[+-]?(?:\d+(?:\.\d+)?|\.\d+|\d{1,3}(?:,\d{3})+(?:\.\d+)?)" if re.fullmatch(pattern, text): number = float(text.replace(",", "")) return number if math.isfinite(number) else pd.NA return pd.NA def typed_pay(values, fields): frame = pd.DataFrame( [value if isinstance(value, dict) else {} for value in values], columns=fields, index=values.index, ) for field in fields: if field in ("min", "max"): frame[field] = frame[field].map(endpoint).astype("Float64") else: frame[field] = frame[field].map( lambda value: value.strip() if isinstance(value, str) and value.strip() else pd.NA ).astype("string") return frame The separator policy is deliberately narrow. Stripping every non-numeric character could turn an unfamiliar salary format into a plausible, wrong number.
A formatted salary string also can't supply structured currency, period and provenance fields by itself. Retain the text for review rather than inferring those attributes from a currency symbol.
Keep empty bands out of the band count
Build the posting table first, then construct the child table while retaining the posting key. Empty lists must contribute no band records: pandas otherwise leaves a placeholder row after expansion.
posting_key = ["companySlug", "id"] postings = raw.reindex( columns=posting_key + ["sourceUrl", "salary", "salaryBands"] ).copy() for field in posting_key + ["sourceUrl"]: postings[field] = postings[field].astype("string") if postings[posting_key].isna().any().any(): raise ValueError("Missing posting key; inspect raw records.") if postings.duplicated(posting_key).any(): raise ValueError("Repeated posting key; resolve duplicates before weighting.") postings["salary_present"] = pd.Series( ["salary" in item for item in items], dtype="boolean" ) postings["salary_structured"] = postings["salary"].map( lambda value: isinstance(value, dict) ).astype("boolean") postings["salary_text"] = postings["salary"].map( lambda value: value if isinstance(value, str) else pd.NA ).astype("string") primary = typed_pay( postings["salary"], ["min", "max", "currency", "period", "range", "source"], ) bands = postings[posting_key + ["salaryBands"]].copy() bands["salaryBands"] = bands["salaryBands"].map( lambda value: value if isinstance(value, list) else [] ) bands = bands.explode("salaryBands", ignore_index=True) bands = bands.loc[ bands["salaryBands"].map(lambda value: isinstance(value, dict)) ].reset_index(drop=True) band_fields = typed_pay( bands["salaryBands"], ["label", "min", "max", "currency", "period", "kind", "source"], ) bands = bands.join(band_fields) The duplicate check stops rather than silently dropping records. An accidental repeated fetch and a legitimate repeated posting are different problems; neither deserves an automatic salary vote.
Only list values are expanded. Unexpected shapes remain in the original columns for inspection rather than acquiring guessed child records.
A posting without child rows remains in postings. That matters when you later explain how many fetched postings supplied usable compensation data.
How much weight did each employer gain?
Count child rows per posting, then compare employer shares before applying any pay eligibility rules.
band_counts = ( bands.groupby(posting_key, dropna=False) .size() .rename("n_bands") .reset_index() ) postings = postings.merge( band_counts, on=posting_key, how="left", validate="one_to_one" ) postings["n_bands"] = postings["n_bands"].fillna(0).astype("Int64") employer_weights = postings.groupby("companySlug", dropna=False).agg( n_postings=("id", "size"), n_bands=("n_bands", "sum"), ) employer_weights["posting_share"] = ( employer_weights["n_postings"] / employer_weights["n_postings"].sum() ) employer_weights["band_share"] = ( employer_weights["n_bands"] / employer_weights["n_bands"].sum() ) This measures disclosure multiplicity in your pull. It doesn't establish that any particular employer publishes more geographic ranges than another.
For a chart filtered to a compensation category, repeat the weight calculation on that eligible subset. Raw band shares can't describe the weighting after exclusions.
Inverse band-count weights might look like a neat repair. They can equalise posting contributions within a carefully defined population, but they can't make OTE equivalent to base pay or make different location zones interchangeable.
We'd rather name the population than hide the decision in a weight.
Give each average its own denominator
A usable midpoint needs endpoints, currency and period. For the band summary, require kind too, so missing classification doesn't quietly enter a named compensation category.
primary_ok = ( primary[["min", "max", "currency", "period"]] .notna().all(axis=1) & primary["min"].le(primary["max"]) ) band_ok = ( bands[["min", "max", "currency", "period", "kind"]] .notna().all(axis=1) & bands["min"].le(bands["max"]) ) postings["base_midpoint"] = ( (primary["min"] + primary["max"]) / 2 ).where(primary_ok) bands["band_midpoint"] = ( (bands["min"] + bands["max"]) / 2 ).where(band_ok) coverage = postings.groupby("companySlug", dropna=False).agg( n_fetched_postings=("id", "size"), n_salary_keys=("salary_present", "sum"), n_structured_primary=("salary_structured", "sum"), n_usable_primary=("base_midpoint", "count"), ) The primary mean now describes postings with usable structured base-pay endpoints. It excludes postings without disclosure, incomplete ranges and values that the parser can't interpret.
Missingness changes the population, not just the error bar.
The worked example is Greenhouse ATS Job Board Lookup by Company. Keep the distinction between its primary summary and its preserved bands visible in the analysis tables.
These DuckDB queries use scalar analysis columns to produce separate posting-level and band-level summaries, each with its own observation count.
posting_pay = postings[posting_key + ["base_midpoint"]].join( primary[["currency", "period"]] ) band_pay = bands[ posting_key + ["currency", "period", "kind", "band_midpoint"] ].copy() connection = duckdb.connect() connection.register("posting_pay", posting_pay) connection.register("band_pay", band_pay) posting_summary = connection.sql(""" SELECT companySlug, currency, period, count(*) AS n_postings, avg(base_midpoint) AS mean_advertised_base_midpoint FROM posting_pay WHERE base_midpoint IS NOT NULL GROUP BY companySlug, currency, period """).df() band_summary = connection.sql(""" SELECT companySlug, currency, period, kind, count(*) AS n_bands, count(DISTINCT id) AS n_contributing_postings, avg(band_midpoint) AS mean_disclosed_band_midpoint FROM band_pay WHERE band_midpoint IS NOT NULL GROUP BY companySlug, currency, period, kind """).df() connection.close() Neither query converts currencies or annualises periods. Those require explicit assumptions; partitioning preserves the distinctions without inventing them.
Keep label and source in the detail table for inspection. A band summary supports a disclosure question, while the posting summary supports a primary advertised base-pay question.
Neither is a count of employees.
The gap between an advert and a pay packet
A midpoint is an analytical construction, not an observed salary. An advertised range doesn't reveal the accepted offer, negotiated pay, hours worked or realised contingent compensation.
Employer comparisons also mix roles and locations unless you explicitly control for them. Giving each posting equal weight fixes the band-count problem; it doesn't make the underlying jobs equivalent.
The primary envelope can't tell you which location band applies to a candidate. The child bands preserve the information needed to investigate that question, but a label still needs interpretation.
Before you defend the average, be able to point to the thing that gets a vote.
Drafted with AI assistance and reviewed for accuracy.
