wiki/attachments/skills/stata-to-python/SKILL.md
将 Stata .do 文件翻译为等效的 Python 脚本。
npx skillsauth add luzhiyu-econ/luzhiyu-econ.github.io stata-to-pythonInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
翻译以下 Stata 代码为 Python:$ARGUMENTS
使用以下对照关系:
| Stata | Python | |---|---| | use "data.dta" | pd.read_stata("data.dta") | | gen x = ... | df["x"] = ... | | replace x = ... if | df.loc[condition, "x"] = ... | | bysort id: gen x = | df.groupby("id")["x"].transform(...) | | merge 1:1 using | pd.merge(df1, df2, on=..., how=...) | | collapse (mean) x, by(id) | df.groupby("id")["x"].agg("mean") | | reghdfe y x, absorb(id year) | from linearmodels import PanelOLS | | outreg2 using | from stargazer.stargazer import Stargazer | | preserve / restore | df_backup = df.copy() | | keep if / drop if | df = df[condition] / df = df[~condition] | | tabstat x, by(group) | df.groupby("group")["x"].describe() | | xtset id year | df = df.set_index(["id", "year"]) |
翻译规范:
tools
构建完整的学术论文复制包(replication package)。
tools
对回归分析结果进行全面诊断。支持 DID、IV、RDD 三种方法。
research
生成学术论文的标准结构框架和 LaTeX 模板。
tools
文献调研和综述辅助。搜索相关文献、提取核心信息、管理 BibTeX 引用。