Part III — Choices and policy · Chapter 9
What taxi records can establish about congestion pricing
Against the Upper East and West Side, trips inside Manhattan's relief zone got about 7% faster in the toll's first weeks and the gain faded within a year; app fares per mile rose. The decline in Uber and Lyft pickups matches a decline a year before the toll, so this design cannot attribute it to the fee.
On this page
- What the meter records
- The fee is per trip, at every hour
- Speeds rose at once and faded
- Trip counts: no step at the start, and declines the design cannot attribute
- Cabs gained share; app dispatch may be why
- Fares per mile rose for apps
- What survives, outcome by outcome
- Explore the zone week by week
- How the pipeline builds the panel
- How this compares with the earlier analysis
- Reusing the design
On January 5, 2025, New York began charging vehicles that enter Manhattan south of 60th Street. Private cars pay at the entry points. Taxi and app rides pay per trip, and that charge appears in the Taxi and Limousine Commission's trip records as a new column, cbd_congestion_fee: $0.75 on a yellow-cab trip and $1.50 on an Uber or Lyft trip. So the meter records the policy: each trip says whether it paid, where it started and ended, how long it took and what it cost.
What changed for trips into and inside the zone: how many there were, how fast they moved, what they cost, and whether riders moved between yellow cabs and apps? This chapter reads 906,936,407 trip records from July 2023 to August 2026, builds a weekly panel in DuckDB, and hands it to pyfixest for an event study. The comparison group is the Upper East and West Side between 60th and 110th Street, which pays no fee but shares the city's weather, calendar and fleets. Most of the chapter's caveats come from that choice.
The short answer: trips inside the zone got faster right away, by about 7% in the first four weeks compared with the same weeks of 2024, and the gain was gone by 2026. The trip counts are harder to read. Uber and Lyft pickups in the zone fell relative to the comparison area after the start, but they fell by a similar amount in 2024, before the toll, so this design cannot attribute the decline to the fee. Yellow-cab pickups show no clear change against the Upper East and West Side, and a decline against a wider Manhattan comparison whose interval includes zero.
Zone speeds jumped when the toll began and faded within a year; trip counts show no step at the start
Trips picked up, % difference
Speed of trips inside the zone, % difference
Estimation (pyfixest)chapters/03-congestion-pricing/pipeline/30_event_study.pyShow SQL
fml = f"n_es ~ i(rel_period, treat, ref={base}) | unit + wht"
fit = pf.fepois(fml, data=d, vcov={"CRV1": "zone_id"})
# seasonal: each bin minus the pre-toll bins at the same point of the 13-bin year
L_sea = np.vstack([L_full[i] - L_full[[j for j in pre if allp[j] % 13 == p % 13]].mean(axis=0)
for i, p in enumerate(allp)])
est, se = L_sea @ b, np.sqrt(np.einsum("ij,jk,ik->i", L_sea, V, L_sea))212,520 unit-weeks per service before pyfixest drops separated cells · 31 s for all fitsRuns at build time in DuckDB 2.0; shown for reading.Open file
What the meter records
The 2025 files add cbd_congestion_fee to both schemas; union_by_name fills it with NULL for earlier months, which the pipeline turns into zero.
The external known value is the MTA's fee schedule: $0.75 per taxi trip and $1.50 per high-volume for-hire trip that touches the zone. The mean fee on charged trips is $0.7500 for yellow cabs and $1.5000 for Uber and for Lyft, to four decimals.
The chapter starts from an earlier analysis in ctzn-pub/nyc-congestion-experiment, which used the same files and the same trip filters; its results files are snapshotted in pipeline/prior/. Its monthly counts serve as a reproduction check. For yellow, Uber and Lyft, every month from July 2023 to July 2026 and every trip class, the trips this pipeline keeps match its counts exactly: a maximum difference of 0 trips across 555 cells.
The fee is per trip, at every hour
Trips flagged as touching the zone carry the fee; other trips mostly do not
| Trip flag · Service | Yellow cab | Uber | Lyft |
|---|---|---|---|
| inside | 99.3%n = 28,487,009 | 99.9%n = 40,925,148 | 98.5%n = 14,798,650 |
| entering | 95.8%n = 10,606,497 | 98.5%n = 21,443,937 | 97.5%n = 9,405,358 |
| leaving | 97.5%n = 11,874,669 | 99.2%n = 26,735,791 | 97.7%n = 10,123,240 |
| boundary | 19.2%n = 8,753,173 | 31.9%n = 8,981,338 | 35.0%n = 3,540,921 |
| outside | 2.5%n = 11,073,245 | 0.8%n = 182,838,706 | 0.9%n = 70,586,138 |
| unknown | 48.3%n = 491,721 | 42.6%n = 13,396,631 | 43.1%n = 4,979,910 |
Querychapters/03-congestion-pricing/pipeline/90_export.sqlShow SQL
SELECT svc, flag, n, n_fee, round(share_fee, 5) AS share_fee FROM fee_check WHERE post ORDER BY svc, flag;18 rowsRuns at build time in DuckDB 2.0; shown for reading.Open file
Does the share of trips with a fee match the share classified as touching the zone? For yellow cabs, 73.2% of trips after the start were charged and 71.5% were classified as touching; for Uber, 33.5% against 30.3%; for Lyft, 33.2% against 30.3%. The gap runs one way, more charged than classified: trips to or from zones with no location were charged 43% to 48% of the time, boundary-ring trips 19% to 35% (part of each boundary zone lies south of 60th Street), and trips flagged outside 0.8% to 2.5%, which fits trips that pass through the zone, such as Brooklyn to the Upper West Side. In the other direction, at most 2.0% of trips classified as touching the zone went uncharged.
The check also corrected an assumption. The earlier analysis described uncharged trips as "overnight, untolled trips" and compared toll hours with free hours (an estimate of −0.115 log points). The per-trip fee does not follow the car toll's hours: in every hour of the day, at least 97.6% of trips picked up in the zone were charged. A peak versus off-peak comparison measures the private-car toll and its traffic effects, not the trip fee.
A handful of charged trips, 1,573, fall in the week before the start; all are in the January 2025 files, in the days before January 5. checks.sql allows that trace and requires zero fees in every earlier week.
Speeds rose at once and faded
The clearest break in Figure 1 is speed. In the first four weeks, trips inside the zone ran 7.2% faster for yellow cabs and 6.7% faster for Uber and Lyft than in the same four weeks of 2024, relative to the core. The evidence on trends is the 2024 placebo, which pretends the toll began a year earlier; because each month is compared only with the same month in other years, it compares July to December 2024 with July to December 2023. It gives +0.1% for yellow and −0.1% for apps. Unadjusted, the pre-toll speed bins swing by about ±6% with the seasons, which is why the adjustment is there.
Averaged over the first toll year, the gain is 3.3% for yellow and 2.8% for apps; over January to August 2026 it is −0.9% and −1.0%. With only 46 zone clusters, the 2025 gains were also tested with a wild cluster bootstrap: p = 0.0025 for yellow and 0.0023 for apps, against 0.85 and 0.64 for the placebos. A sharp break on the start date with a near-zero placebo is the strongest pattern a design like this can show. It is still a comparison with eight zones a few miles north, which may have gained some speed of their own from lighter traffic on the approach roads; if they did, the zone's gain is understated.
Inside the zone, the speed distribution shifted right in 2025 and back in 2026
Querychapters/03-congestion-pricing/pipeline/90_export.sqlShow SQL
SELECT period AS frame, svc AS "group", list({'lo': lo, 'hi': hi, 'count': count} ORDER BY lo) AS bins
FROM speed_hist WHERE area = 'Inside the zone' GROUP BY ALL ORDER BY frame, "group";6 frames · 354 binsRuns at build time in DuckDB 2.0; shown for reading.Open file
Yellow trips inside the core slowed over the same years, from 8.73 to 8.51 to 8.32 mph.
Trip counts: no step at the start, and declines the design cannot attribute
For Uber and Lyft, pickups in the zone fell 4.7% relative to the core over the whole post period, and the decline grew from 3.2% in 2025 to 7.5% in 2026. Read alone, that looks like a response to the $1.50 fee. The placebo finds a decline of the same size during 2024, before the toll: July to December 2024 against July to December 2023 gives −4.4%. So this design cannot attribute the decline to the fee: the fee may have added to a trend already under way, or the trend may account for all of it. Most of the relative decline belongs to Uber, whose estimate is −7.0% with a placebo of −7.5%; Lyft's is +2.3% with a placebo of +3.1%.
Yellow-cab pickups in the zone show no clear change against the core: +0.5%, with an interval from −3.8% to +5.0%, and a placebo of −0.4%. The yearly estimates, +3.2% in 2025 and −4.8% in 2026, are not distinguishable from zero.
Adding the 12 Manhattan zones north of 110th Street to the control group (20 zones) changes both numbers. Apps: −8.5% (−10.2% to −6.6%), with a placebo of −5.9%. Yellow: −7.4% (−15.4% to +1.4%), with a placebo of −2.6%. The app decline is again close to its placebo. The yellow estimate is larger than its placebo, but its interval includes zero, and yellow pickups north of 110th Street and on the islands grew 70% from the year before the start to the year after, which the earlier analysis linked to app dispatch. Neither control group shows a step in trip counts at the start date.
Raw counts, with no comparison group, look different again: from January–August 2024 to the same weeks of 2025, yellow trips touching the zone rose 10.2%, Uber's fell 10.6% and Lyft's rose 9.1%. But yellow pickups grew almost everywhere: from the year before the start to the year after, 8.5% in the zone, 4.6% in the UES/UWS core and 144% in the outer boroughs.
Yellow pickups grew across the city, most in the outer boroughs; app pickups fell in Manhattan's core zones
Yellow cab
Uber + Lyft
Querychapters/03-congestion-pricing/pipeline/90_export.sqlShow SQL
COPY (
SELECT z.id AS LocationID, c.zone, c.borough, c.zclass, ch.pu_pct_yellow, ch.pu_pct_app, z.geom
FROM zone_geom z JOIN zone_class c USING (id) LEFT JOIN zone_change ch ON ch.zone_id = z.id)
TO '../../public/data/congestion-pricing/zone_change.geojson'
(FORMAT gdal, DRIVER 'GeoJSON', LAYER_CREATION_OPTIONS ('COORDINATE_PRECISION=5', 'RFC7946=YES'));263 zones · 586 KB GeoJSONRuns at build time in DuckDB 2.0; shown for reading.Open file
The same layer, by hour of day and for dropoffs too, is exported for the Map Lab as maplab_zone_change.geojson.
Cabs gained share; app dispatch may be why
Yellow cabs' share of trips touching the zone rose in 2025; the core's share did not
The yellow share of trips touching the zone went from 26.7% to 29.3% to 29.1% across 2024, 2025 and 2026, while the share inside the core stayed near 52% and then slipped to 50.5%. The relative rise in the figure's caption has a bootstrap p of 0.18.
The growth is in one meter vendor: on trips touching the zone, vendor 2 went from 14.1 to 16.0 million trips between January–August 2024 and 2025, while vendor 1 went from 4.2 to 4.1 million. The new request_source column suggests why: from June to August 2026, 23.7% of yellow trips touching the zone and 21.5% of other yellow trips carry an Uber or Lyft licence code (HV0003 or HV0005) as their source. App dispatch of yellow cabs may have grown over the whole period, but the files record it only from June 2026, so its growth cannot be separated from the toll.
Fares per mile rose for apps
Uber and Lyft's base fare per mile, which excludes the fee, rose 8.6% relative to the core in 2025 and 16.7% in 2026; the 2024 placebo is +2.7%. The wild cluster bootstrap gives p = 0.0005 for both years. It is the largest change in the chapter that clearly exceeds its placebo, and it comes on top of the $1.50 fee. Yellow fare per mile fell 0.9% in 2025, consistent with faster trips on a meter that charges for slow time, then rose 6.9% in 2026; this pipeline does not identify the cause of the 2026 rise.
Speed and app fares move beyond their placebos; trip counts do not
Querychapters/03-congestion-pricing/pipeline/30_event_study.pyShow SQL
did("pooled", "trips", svc, "core", pf.fepois("n_es ~ did | unit^moy + wht", data=d, vcov={"CRV1": "zone_id"}), ["did"])
pre = d[d.rel_week < 0]
did("placebo_2024", "trips", svc, "core",
pf.fepois("n_es ~ did_placebo | unit^moy + wht", data=pre, vcov={"CRV1": "zone_id"}), ["did_placebo"])41 estimates from 31 models · 31 s with the event studiesRuns at build time in DuckDB 2.0; shown for reading.Open file
What survives, outcome by outcome
Each outcome faced the same test: a change at the start date, compared with the eight core zones, set against the same comparison run a year early, when there was no toll.
| Outcome | What the design shows | What it cannot rule out |
|---|---|---|
| Speed inside the zone | A jump of about 7% in the first four weeks, near-zero placebo, gone by 2026 | Core zones gaining speed too, which would make the jump an understatement |
| Uber and Lyft pickups | A relative decline about the size of its 2024 placebo | A trend already under way; the fee may add to it or explain none of it |
| Yellow-cab pickups | No clear change against the core; a decline against a wider control whose interval includes zero | Growth in app dispatch of yellow cabs, recorded only from June 2026 |
| Yellow share of trips | A small rise that the bootstrap cannot separate from noise | The same app-dispatch change |
| Uber and Lyft fare per mile | The largest change that clearly exceeds its placebo, growing in 2026 | Pricing decisions made for reasons other than the fee |
Only speed and app fares per mile pass the placebo test, and only speed shows a break on the start date. That is the defensible reading of these records: the toll's first months coincided with faster trips in the zone, and nothing in the trip counts can be attributed to it with this design.
Explore the zone week by week
The dashboard below runs the chapter's data in your browser. The pipeline's live step (91_export_live.sql) writes six tables from the same staged aggregates as the panel: weekly trips by service and trip flag, weekly speeds by area, every Manhattan pickup zone by week and summed over each year, and pickups and dropoffs by zone and hour for the year before and the first toll year, 1.3 MB on public storage. DuckDB-Wasm reads them over HTTP range requests. Pick a service and toll or all hours and every panel is recomputed; each shows its SQL. These are before-and-after descriptions without the season adjustment and comparison area of the estimates above, so a change here is not an effect of the toll. The Ask box at the bottom hands your question to an AI model that writes the SQL; the query runs here, on the same files, and the model only sees the small result. Its answers are live and unaudited, unlike the numbers above.
Live · runs in your browser
Manhattan's congestion relief zone, taxi and app trips, July 2023 to August 2026
- Engine
- DuckDB 2.0.1 · Wasm
- Data read
- 0 B of 1.3 MB
The chapter's data sits in 6 Parquet files on public storage, 1.3 MB in all. Start the engine and DuckDB runs inside this page: each chart below is a SQL query that reads only the row groups and columns it needs over HTTP range requests.
weeklyTrips by week, service and trip flag (inside, entering, leaving the zone…)speedTrips within an area by week, service, area and toll hours, with miles and hourszone_weeksManhattan pickup zones by week, service and toll hourszone_periodsManhattan pickup zones, year before vs first toll year, by service and toll hourszone_hoursPickups and dropoffs by zone and hour, year before vs first toll yearzonesTaxi zones with borough and area class
Queries this chapter's published snapshot; the data does not update in real time. No account, nothing uploaded.
How the pipeline builds the panel
Find 60th Street in the shapefile
The relief zone is Manhattan south of 60th Street, and taxi zones do not follow that line. Central Park runs from 59th to 110th Street, parallel to the avenues, so its minimum rotated rectangle gives both the direction of the street grid and the position of 59th Street.
10_stage.sqlSQL CREATE OR REPLACE TABLE grid AS WITH r AS ( SELECT list_transform(ST_Dump(ST_Points(ST_MinimumRotatedRectangle(geom))), lambda p: {'x': ST_X(p.geom), 'y': ST_Y(p.geom)}) AS c FROM zone_shapes WHERE LocationID = 43), -- Central Park sides AS ( -- two adjacent sides; the longer one runs along the avenues SELECT c, CASE WHEN (c[2].x - c[1].x)^2 + (c[2].y - c[1].y)^2 > (c[3].x - c[2].x)^2 + (c[3].y - c[2].y)^2 THEN [c[2].x - c[1].x, c[2].y - c[1].y] ELSE [c[3].x - c[2].x, c[3].y - c[2].y] END AS v FROM r), d AS (SELECT c, sign(v[2]) * v[1] / sqrt(v[1]^2 + v[2]^2) AS ux, sign(v[2]) * v[2] / sqrt(v[1]^2 + v[2]^2) AS uy FROM sides) SELECT ux, uy, list_min(list_transform(c, lambda p: p.x * ux + p.y * uy)) AS u_59th, list_max(list_transform(c, lambda p: p.x * ux + p.y * uy)) AS u_110th, (u_110th - u_59th) / 51 AS block_ft, u_59th + block_ft AS u_60th FROM d;The rectangle comes out at 29.0° from true north with 266.5 feet per block, which matches the familiar tilt of the Manhattan grid and its twenty blocks to the mile (5,280 ÷ 266.5 = 19.8).
1 row: grid at 29.0° from north, 266.5 ft per blockchapters/03-congestion-pricing/pipeline/10_stage.sql
Classify every zone by its area south of the line
A half-plane south of the 60th Street line, built as a large rotated polygon, is intersected with each zone. Zones at least 90% south of it are in the relief zone; zones that straddle it form a boundary ring; Manhattan zones between 60th and 110th Street are the comparison core.
10_stage.sqlSQL SELECT id, zone, share_south, CASE WHEN borough = 'Manhattan' AND id IN (103, 104, 105, 194, 202) THEN 'manh_other' -- islands WHEN borough = 'Manhattan' AND share_south >= 0.90 THEN 'crz' WHEN borough = 'Manhattan' AND share_south > 0.01 THEN 'boundary' WHEN borough = 'Manhattan' AND mi_north_of_60th < mi_60th_to_110th THEN 'core' WHEN borough = 'Manhattan' THEN 'manh_other' WHEN zone ILIKE '%airport%' THEN 'airport' ELSE 'outer' END AS zclass FROM (SELECT s.*, ST_Area(ST_Intersection(s.geom, hp.south)) / ST_Area(s.geom) AS share_south, … FROM zone_shapes s, hp)The rule returns 38 relief-zone zones, a six-zone boundary ring (Central Park, Lincoln Square East and West, Lenox Hill East and West, Upper East Side South) and an eight-zone core. These are the same lists the earlier analysis chose empirically, from the share of each zone's trips that carried the fee, so the geometry and the meter agree before any trips are read.
265 zones: 38 relief zone, 6 boundary, 8 UES/UWS core · 0.3 s with step 1chapters/03-congestion-pricing/pipeline/10_stage.sql
One scan, six aggregates
Reading 907 million rows is the expensive part, so it should happen once.
GROUPING SETScomputes several aggregates in one pass; each set's unused columns come backNULL, and agrouping()test names the set.10_stage.sqlSQL SELECT CASE WHEN grouping(pu_manh) = 0 THEN 'panel' WHEN grouping(pu) = 0 THEN 'map_pu' WHEN grouping(do_) = 0 THEN 'map_do' WHEN grouping(spd_bin) = 0 THEN 'speed' WHEN grouping(pu_cls) = 0 THEN 'class' ELSE 'log' END AS gset, service, week, hr, tolled, pu_manh, pu_cls, do_cls, period, pu, do_, do_hr, spd_bin, vendor, file_month, status, count(*) AS n, count(*) FILTER (WHERE fee > 0) AS n_fee, sum(fee) AS fee, sum(fare) AS fare, sum(miles) AS miles, count(*) FILTER (WHERE spd_ok) AS n_spd, sum(miles) FILTER (WHERE spd_ok) AS miles_spd, sum(dur_s) FILTER (WHERE spd_ok) / 3600.0 AS hours_spd FROM k GROUP BY GROUPING SETS ( (service, week, hr, tolled, pu_manh, do_cls), -- weekly Manhattan zone x hour panel (service, period, hr, pu), (service, period, do_hr, do_), -- maps (service, week, tolled, pu_cls, do_cls, spd_bin), -- speed histogram (service, week, file_month, tolled, pu_cls, do_cls, vendor), -- flags, fees, fares (service, file_month, status)); -- rows kept and droppedThe per-trip logic sits in a table macro shared by both sources: trips are kept if they start in their file's month, last 1 to 180 minutes, cover 0.1 to 100 miles and have a fare of $0 to $500. That keeps 93.5% of yellow and 99.9% of FHVHV records. Speed is distance over duration, counted only for trips of at least 2 minutes and 0.2 miles at 1 to 60 mph.
Yellow 138 M rows in 53 s; FHVHV 768 M rows in 360 s; 6.1 M aggregate rowschapters/03-congestion-pricing/pipeline/10_stage.sql
Check the fee against the flags
Each trip is flagged inside (both ends in the zone), entering (dropoff only), leaving (pickup only), boundary or outside. If the classification is right, trips flagged as touching the zone should carry the fee and the rest should not.
90_export.sqlSQL CREATE OR REPLACE TABLE fee_check AS SELECT CASE WHEN service = 'yellow' THEN 'Yellow cab' WHEN service = 'uber' THEN 'Uber' ELSE 'Lyft' END AS svc, flag, (rel_week >= 0) AS post, sum(n) AS n, sum(n_fee) AS n_fee, sum(fee) AS fee, sum(n_fee) / sum(n) AS share_fee, sum(fee) / nullif(sum(n_fee), 0) AS fee_per_charged_trip FROM trip_class_weekly WHERE service IN ('yellow', 'uber', 'lyft') GROUP BY ALL;They do: 99.3% of yellow and 99.9% of Uber trips inside the zone were charged, against 2.5% and 0.8% of trips flagged outside. Figure 2 has the full table.
36 rows, 18 after the startchapters/03-congestion-pricing/pipeline/90_export.sql
Build the weekly zone × hour panel and hand it off
The model unit is a pickup zone × hour of day × peak flag, observed every week. Weeks with no trips must appear as zeros, so the panel is a cross join of units and weeks, left-joined to the counts. Control zones count only trips that stay out of the zone, because a trip from the Upper East Side to Midtown pays the fee.
20_model.sqlSQL CREATE OR REPLACE TABLE panel AS WITH units AS (SELECT DISTINCT service, svc, zone_id, zclass, hr, tolled FROM panel_cells) SELECT u.*, w.week, w.rel_week, w.rel_period, (u.zclass = 'crz')::INTEGER AS treat, (w.rel_week >= 0)::INTEGER AS post, coalesce(c.n_es, 0) AS n_es, coalesce(c.n_spd_int, 0) AS n_spd_int, c.miles_spd_int, c.hours_spd_int FROM units u CROSS JOIN weeks w LEFT JOIN panel_cells c ON c.service = u.service AND c.zone_id = u.zone_id AND c.hr = u.hr AND c.tolled = u.tolled AND c.week = w.week; COPY (FROM panel ORDER BY svc, service, zone_id, hr, tolled, week) TO 'out/panel.parquet' (FORMAT parquet, COMPRESSION zstd);Python loads it in 0.9 seconds, and pyfixest fits the four event studies and 31 difference-in-differences models, 41 estimates in all, in 31 seconds, including a wild cluster bootstrap for the OLS terms.
840,345 rows · 17.6 MB parquet · 2.3 schapters/03-congestion-pricing/pipeline/20_model.sql
How this compares with the earlier analysis
This chapter reproduces the earlier analysis's trip counts and zone lists exactly and agrees on speed, but not on trip counts or cab share as effects of the toll. Its unit is a pickup zone rather than a trip class, it compares each month with the same month in other years, and it runs a placebo for every outcome; under that design the app decline is close to its placebo and the yellow and cab-share intervals include zero. Estimates below are log points × 100 (95% interval), the unit both analyses use.
| Finding | Earlier analysis | This chapter |
|---|---|---|
| Zone, boundary and core lists | 38 / 6 / 8 zones, from fee shares | Same lists, from geometry |
| Kept trips per month and trip class | 555 cells | Identical (0 difference) |
| Yellow trips, zone vs core | +12.1 (trips touching the zone) | +0.5 (−3.9 to +4.9) (zone pickups) |
| Uber + Lyft trips, zone vs core | −8.2, placebo −3.2 | −4.8, placebo −4.5; wider control −8.8, placebo −6.1 |
| Taxi share, log-odds | +18.9 | +6.2 (−2.1 to +14.6) |
| Uber + Lyft speed, 2025 / 2026 | +2.3 / −1.4 (event-study means) | +2.8 / −1.0 (difference-in-differences) |
| Hours the fee applies | Modelled as toll hours vs free hours | Every hour (≥ 97.6% of zone pickups charged) |
Reusing the design
For any question of the form "what changed for these places after this date" (a policy boundary, a store opening, a new transit line):
- Classify places with geometry you can show, keeping the share of each unit inside the treated area; units that straddle the line get their own group.
- Aggregate once, at the grain the models need.
GROUPING SETSlets one scan feed every downstream table. - Zero-fill the panel in SQL and hand the model a parquet file, types intact.
- Give every estimate a placebo, and try a second control group. Here they decided the reading of the largest trip-count result.
A minimal version, for one source and one treated area:
CREATE TABLE units AS
SELECT LocationID AS unit,
ST_Area(ST_Intersection(geom, $treated_area)) / ST_Area(geom) >= 0.9 AS treated
FROM ST_Read('zones.shp');
CREATE TABLE cells AS
SELECT PULocationID AS unit, hour(ts) AS hr,
CAST(ts AS DATE) - CAST(dayofweek(ts) AS INTEGER) AS week, count(*) AS n
FROM read_parquet($urls) GROUP BY ALL;
COPY (
SELECT u.unit, h.hr, w.week, u.treated::INT AS treated, coalesce(c.n, 0) AS n
FROM units u
CROSS JOIN (SELECT DISTINCT hr FROM cells) h
CROSS JOIN (SELECT DISTINCT week FROM cells) w
LEFT JOIN cells c USING (unit, hr, week)
) TO 'panel.parquet';import duckdb, pandas as pd, pyfixest as pf
df = duckdb.connect().execute("FROM 'panel.parquet'").df()
df["rel_week"] = (df.week - pd.Timestamp("2025-01-05")).dt.days // 7
fit = pf.fepois("n ~ i(rel_week, treated, ref=-1) | unit^hr + week^hr",
data=df, vcov={"CRV1": "unit"})The fit returns one coefficient per week relative to the week before the change. Add the seasonal adjustment from 30_event_study.py if the treated places have a different yearly rhythm from the controls, as Midtown and the Upper West Side do.
cd chapters/03-congestion-pricing && mkdir -p out/.tmp
duckdb out/ch03.duckdb -c ".read pipeline/00_sources.sql" -c ".read pipeline/10_stage.sql" -c ".read pipeline/20_model.sql"
python pipeline/30_event_study.py
duckdb out/ch03.duckdb -c ".read pipeline/00_sources.sql" -c ".read pipeline/90_export.sql" -c ".read pipeline/checks.sql"The timed run took 8 minutes (480 seconds through 90_export.sql) on a shared 4-core cloud machine with two DuckDB threads and a 2.5 GB memory limit; 360 seconds of it is the FHVHV scan. It went through the local relay described in the README, which downloads whole files because TLC's CDN rate-limited this machine; reading in place fetches less (9.9 GB instead of 21.0 GB) but makes thousands more requests. Full pipeline: chapters/03-congestion-pricing/pipeline.