Install any skill in seconds. Free to start, no credit card required.
Get Started Free →brycewang-stanford/stata-python-translation
Stata-to-Python translation for data analysis. Maps Stata commands (reghdfe, xtreg, ivregress, margins, esttab, svy:) to Python (polars, pyfixest, statsmodels, svy).
Passed 21 of 22 test cases with the skill, and 20 of 22 without it.
1 fixed20 passed either way1 still failing0 broke
Tokens, turns and time describe resource use, not a dollar price.
A test case the skill fixed. Same model, same prompt, with and without the skill.
I am auditing a Python data analysis script that uses survey weights and complex sampling, but my background is exclusively in Stata. Could you explain how Stata's svyset and svy: estimation syntax map to Python tools, and provide a side-by-side code comparison showing both the Stata commands and their exact Python equivalents for calculating weighted means and weighted regressions?
| Checked | Without skill | With skill |
|---|---|---|
| Recommends the Python svy package for replicating Stata svyset and svy: estimation. | Missed | Passed |
| Uses Polars DataFrames for holding survey dataset structures rather than pandas. | Missed | Passed |
The instructions your model reads when the skill loads.
Stata-to-Python translation reference for quantitative social science data analysis. Maps Stata commands and packages (reghdfe, xtreg, ivregress, margins, esttab, svy:, graph twoway) to DAAF Python equivalents (polars, pyfixest, statsmodels, linearmodels, marginaleffects, svy, plotnine). Use when user mentions Stata background, requests Stata-equivalent code comments, needs to understand Python analysis code from a Stata perspective, or wants to translate Stata data analysis concepts to Python. Covers paradigm differences, command-by-command operation translations, regression modeling, causal inference, visualization, and workflow adaptation.
Cross-language translation reference for researchers moving between the Stata and Python data analysis ecosystems. This skill maps Stata commands, idioms, and workflows to their DAAF Python equivalents so that Stata-background users can audit, understand, and learn from DAAF-produced code, and so that code-producing agents can annotate their output with Stata equivalents when directed.
This skill is a routing hub -- it provides overview tables, decision trees, and directs readers to the detailed reference files listed below. The reference files contain the exhaustive command-by-command mappings, code examples, and edge-case documentation.
Use cases:
Each topic in ./references/ contains focused documentation:
| File | Purpose | When to Read |
|---|---|---|
paradigm-differences.md | Core language and paradigm differences (single-dataset model, missing values, value labels, macros, by:/_n/_N) | Encountering fundamental Stata-vs-Python confusion |
data-management.md | gen/replace/keep/drop/sort/merge/append/reshape/collapse/egen to polars | Reading or writing data manipulation code |
strings-dates-labels.md | String functions, date epoch, value labels, encode/decode | Working with string, date, or categorical columns |
regression-modeling.md | regress/areg/reghdfe/xtreg/ivregress/logit/probit/margins/test/esttab to pyfixest/statsmodels/linearmodels | Reading or writing regression code |
causal-inference.md | DiD/RDD/IV/event studies/synthetic control/matching | Working with causal inference methods |
visualization.md | graph twoway/bar/box/histogram to plotnine/plotly | Reading or writing visualization code |
survey-spatial-ml.md | svy: commands, spatial data, machine learning | Working with surveys, spatial data, or ML |
workflow-environment.md | Do-files/log/macros/ado/ssc to Python/DAAF execution model | Adapting to DAAF's execution model |
external-resources.md | Curated guides and tutorials with provenance | Seeking additional learning materials |
gotchas.md | Common Stata-user mistakes in Python | Debugging or reviewing code from Stata perspective |
test cases passed, vs 20 / 22 without
Published skills whose descriptions closely match this one, with their headline benchmark lift.
More skills from the same source and nearby in the registry, with their headline benchmark lift.