pipeline
Classical end-to-end empirical analysis workflow in the traditional Python econometric stack — pandas + numpy + scipy +…
County Presidential Returns 2000-2024 (MIT MEDSL). Vote shares, party trends, turnout by county_fips (joins census/education data). Requires HARVARD_DATAVERSE_API_KEY. Critical: mode='TOTAL' drops ~1K counties post-2020 — use 3-pattern reconstruction
Claude Code
$ npx -y skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill election-data-source-countypres --agent claude-code
Codex
$ npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill election-data-source-countypres -a codex -y
Cursor
$ npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill election-data-source-countypres -a cursor -y
Gemini CLI
$ npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill election-data-source-countypres -a gemini-cli -y
GitHub Copilot
$ npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill election-data-source-countypres -a github-copilot -y
OpenCode
$ npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill election-data-source-countypres -a opencode -y
Windsurf
$ npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill election-data-source-countypres -a windsurf -y
name: election-data-source-countypres description: >- County Presidential Returns 2000-2024 (MIT MEDSL). Vote shares, party trends, turnout by county_fips (joins census/education data). Requires HARVARD_DATAVERSE_API_KEY. Critical: mode='TOTAL' drops ~1K counties post-2020 — use 3-pattern reconstruction metadata: audience: any-agent domain: data-source skill-authored: "2026-02-23" skill-last-updated: "2026-02-24"
County Presidential Election Returns 2000-2024 from MIT Election Data and Science Lab (MEDSL). Use when analyzing county-level presidential vote shares, party trends, turnout, or geographic voting patterns. Key join column county_fips enables linking to census, education (CCD/SAIPE), and demographic datasets. Requires Harvard Dataverse API key (HARVARD_DATAVERSE_API_KEY env var). Categorical variables use uppercase strings, not Portal integer codes. Critical caveat: naive mode='TOTAL' filtering silently drops ~1,000 counties in 2020+ data — use 3-pattern reconstruction.
The authoritative source for county-level U.S. presidential election returns spanning 2000-2024. Provides candidate-level vote counts across all 50 states and DC, enabling vote share analysis, partisan trend mapping, and cross-domain geographic research via FIPS code joins.
> **CRITICAL: Value Encoding** > > This dataset uses **uppercase string codes** for categorical variables (party, mode, > candidate, state) rather than integer codes. Empty strings (`""`) appear as > undocumented values in `party` (501 rows, 2024) and `mode` (2,795 rows, 2024). > > | Context | party | mode | candidate | > |---------|-------|------|-----------| > | **Standard values** | `DEMOCRAT`, `REPUBLICAN` | `TOTAL` | `BARACK OBAMA` | > | **Aggregate/meta values** | `OTHER`, `""` | `""`, `ELECTION DAY` | `OTHER`, `UNDERVOTES` | > > See `./references/variable-definitions.md` for complete encoding tables.
> **API Key Required:** This data source requires a **Harvard Dataverse API key** to fetch data. > Unlike education data sources (which use the Urban Institute's free, unauthenticated API), > election data is hosted on Harvard Dataverse and requires authentication. > > **Setup instructions:** > 1. Create a free Harvard Dataverse account at https://dataverse.harvard.edu/ > 2. Log in, navigate to your account name (top-right) → API Token > 3. Click "Create Token" and copy it > 4. Set the environment variable **before launching Claude Code**: > ```bash > export HARVARD_DATAVERSE_API_KEY="your_token_here" > ``` > For Docker users: run this inside the container after `docker compose exec daaf-docker bash` > but before `claude`. To make it persistent across sessions, add it to `~/.bashrc`. > > **If the key is missing**, any fetch script will fail with a `KeyError: 'HARVARD_DATAVERSE_API_KEY'`. > The orchestrator should check for this variable's existence before dispatching Stage 5 fetch tasks > that use this data source.
| File | Purpose | When to Read | |------|---------|--------------| | `variable-definitions.md` | Complete column specs, party/mode/candidate value tables | Interpreting specific columns or coded values | | `coded-values.md` | All categorical value mappings with frequencies | Filtering or recoding party, mode, candidate | | `columns.md` | Detailed per-column profiling (types, nulls, ranges) | Understanding column characteristics | | `quality-notes.md` | Known issues, anomalies, duplicates, null patterns | Assessing data reliability | | `mode-reconstruction.md` | 3-pattern TOTAL mode reconstruction for 2020+ data | Cleaning any 2020+ analysis (CRITICAL) | | `interpretations.md` | Preliminary semantic interpretations (flagged for review) | Understanding column meanings |
Analyzing presidential election data? ├─ County-level vote shares → Use 3-pattern mode reconstruction (./references/mode-reconstruction.md) │ └─ Longitudinal (cross-year) → MUST reconstruct TOTAL for 2020+ (naive filter drops ~1,000 counties) │ └─ Single year (pre-2020) → Safe to filter mode='TOTAL' │ └─ Single year (2020/2024) → Reconstruct unless analyzing a known TOTAL-only state ├─ Party trends → Group by year + party, use party column (not candidate name) │ └─ Third parties → See ./references/coded-values.md (GREEN/LIBERTARIAN vary by year) ├─ Turnout analysis → Use totalvotes column (dedup per county-year before summing!) ├─ Joining with other data → Use county_fips as join key (zero-pad to 5 chars first!) │ └─ Census/ACS data → Join on county_fips (standard 5-digit string) │ └─ Education data (CCD/SAIPE) → Join on county_fips │ └─ Null FIPS? → See ./references/quality-notes.md (CT, ME, RI) └─ Voting method analysis → 2020 and 2024 only, see mode breakdown
Unexpected values? ├─ county_fips is null → CT/ME/RI in pre-2020 years (52 rows) ├─ county_fips > 72999 → Kansas City MO (FIPS 2938000, non-standard) ├─ county_fips join failures → Zero-pad to 5 chars! (AR codes = 4 digits as int) ├─ AR FIPS 5135 has two counties → Source data error: St. Francis under Sharp County │ └─ See ./references/quality-notes.md #arkansas-fips-conta
## 🔥 力荐 · StatsPAI — Stata 与 R 的 Python 平替,为 AI Agent 而生 🔁 Stata / R 平替:reghdfe、csdid、rdrobust、synth、fixest、did 等常用命令在 Python 中一站式替代,一个 import statspai as sp 搞定 DID / RD / IV / SCM / DML / matching 🤖 面向 Agent 设计:结构化结果对象 + 内置 MCP Server,Claude / Codex
Classical end-to-end empirical analysis workflow in the traditional Python econometric stack — pandas + numpy + scipy +…
Use when the user asks to run a full empirical / causal analysis in Python — by default in the style of an applied economics…
Classical end-to-end empirical analysis workflow in the traditional Python econometric stack — pandas + numpy + scipy +…
Classical end-to-end empirical analysis workflow in the traditional Stata ecosystem — native Stata + reghdfe + ivreg2 + csdid +…
Classical end-to-end empirical analysis workflow in the modern tidyverse + econometrics R ecosystem — dplyr + tidyr + haven +…
Systematic writing framework for philosophy and interdisciplinary academic papers from optimized outline to submission-ready…
Direct browser control via CDP for web interaction: automation, scraping, testing, screenshots, and site/app work. Also covers…
Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling…