场景定位
用 Codex 清洗数据、连接多份来源、探索假设、建立可解释模型,并把结果打包成图表、备忘录、仪表盘或可复跑报告。
- 难度
- 中级
- 时间跨度
- 约 1 小时
适合用于
- 从杂乱文件开始,最终需要图表、备忘录、仪表盘或报告的数据分析
- 希望 Codex 协助清洗、连接、探索分析和生成可复现脚本的分析师
- 需要可审查交付物,而不是一次性 notebook 状态的团队
Skills & Plugins
相关工具
Starter Prompt
起步提示词
I'm doing a data analysis project in this workspace.
Goal:
- Figure out whether houses near the highway have lower property valuations.
Start by:
- reading `AGENTS.md` and explaining the recommended Python environment
- loading the dataset(s) at [dataset path]
- describing what each file contains, likely join keys, and obvious data quality issues
- proposing a reproducible workflow from import and tidy through visualization, modeling, and report output
Constraints:
- prefer scripts and saved artifacts over one-off notebook state
- do not invent missing values or merge keys
- suggest any skills or worktree splits that would make the workflow more reproducible
Output:
- setup plan
- data inventory
- analysis plan
- first commands or files to create 在 ChatGPT 桌面应用中尝试 介绍
数据分析的核心是用数据支持决策,目标不是为了分析而分析,而是产出能帮助别人行动的交付物:给领导看的图表、给产品团队看的实验复盘、给研究团队看的模型评估,或支撑日常运营的仪表盘。
一个有用的框架来自 R for Data Science:先 import 和 tidy 数据,然后在 transform、visualize 与 model 之间循环建立理解,最后再 communicate 结果。编程围绕整个循环展开。
Codex 适合放进这个流程。它能更快地清洗数据、探索假设、生成分析并产出可复现交付物。目标不是一次性的 notebook,而是别人能审查、信任并重新运行的工作流。
定义你的分析问题
先选择一个你希望用数据回答的具体问题。问题越具体,Codex 越容易理解你的目标,并判断该如何帮你达成结果。
官方示例问题是:高速公路附近的房屋估值在多大程度上更低?
假设一个数据集包含房屋估值或成交价格,另一个数据集包含位置、地块或距离高速公路的信息。工作并不只是跑一个模型,而是让输入可信、记录连接方式、压力测试结果,并产出别人能使用的交付物。
设置环境
开始新的数据分析项目时,需要先设置环境并定义项目规则。
- 环境:Codex 应该知道项目使用哪个 Python 环境、包管理器、文件夹和输出约定。
- Skills:notebook 清理、电子表格导出、最终报告打包这类重复流程,应该沉淀成可复用 skills。
- Worktrees:把不同探索拆到不同 worktree,避免一个假设、连接策略或可视化分支污染另一个方向。
## Data analysis defaults
- Use `uv run` or the project's existing Python environment.
- Keep source data in `data/raw/` and write cleaned data to `data/processed/`.
- Put exploratory notebooks in `analysis/` and final artifacts in `output/`.
- Never overwrite raw files.
- Prefer scripts or checked-in notebooks over unnamed scratch cells.
- Before merging datasets, report candidate keys, null rates, and join coverage. 导入数据
最快的开始方式通常是粘贴文件路径,让 Codex 先检查数据。不要一上来要求结论,先要求 inventory 和解释。
- 这里有哪些文件格式?
- 每个数据集看起来代表什么?
- 哪些列可能是目标、标识符、日期、位置或度量?
- 哪些明显质量问题需要先处理?
整理并连接输入
真实工作往往从这里开始:有两个或更多数据集,主键并不清楚,天真的 merge 可能丢失数据或制造重复。
在真正执行合并前,要求 Codex 先 profile 连接方案,并说明候选键的唯一性、空值率、格式差异、试连接匹配率和推荐策略。
如果需要派生最佳连接键,例如标准化地址、由多个列组合成地块标识,或做位置连接,让 Codex 在你接受合并前解释取舍和边界情况。
- 检查候选键唯一性。
- 测量空值率和格式差异。
- 标准化大小写、空格、地址格式等明显问题。
- 运行试连接并报告匹配率。
- 推荐最安全的合并策略,再写入最终合并文件。
用图表和独立 worktrees 探索
探索性数据分析需要干净隔离。一个 worktree 可以测试地址清理或特征工程,另一个专注图表或不同建模方向。这样每个 diff 都更容易审查,也避免一个长对话混入互相冲突的想法。
在高速公路房屋示例里,这一步会比较高速附近与更远位置的房屋、检查异常值、观察缺失值模式,并判断看到的效应是确实存在,还是由社区结构、房屋面积或其它因素造成。
git worktree add ../analysis-highway-eda -b analysis/highway-eda
git worktree add ../analysis-model-comparison -b analysis/highway-modeling 对问题建模
不是每个分析都需要复杂模型。先从可解释基线开始。
对高速公路问题,一个合理的一阶方案是回归或其它透明模型,用房屋面积、房龄、位置等相关因素做控制,估计高速距离和房产价值之间的关系。
如果第一个模型很弱,这依然有价值。它能说明问题出在模型、特征、连接质量,还是问题定义本身。
- 目标变量和特征定义。
- 包含哪些控制变量以及原因。
- 泄漏风险和需要排除的变量。
- 拆分、评估或不确定性估计方式。
- 用普通语言解释结果意味着什么。
传达结果
分析只有在别人能消费时才有用。要求 Codex 产出适合受众的交付物,并清楚写出 caveats。
如果连接质量不完美、存在采样偏差,或模型假设脆弱,Codex 应该在交付物里明说,而不是把限制藏起来。
- 给技术协作者看的 Markdown memo。
- 给下游运营工作使用的 spreadsheet 或 CSV。
- 需要版式和表格时,用 $doc 产出 .docx brief。
- 用 $pdf 渲染 appendix 或最终交付物。
- 用 $vercel-deploy 部署轻量 dashboard 或静态报告站点。
可考虑的 skills
适合这个工作流的 curated skills 包括 $spreadsheet、$jupyter-notebook、$doc、$pdf 和 $vercel-deploy。
工作流稳定后,为重复部分创建仓库本地 skills,例如 refresh-data、merge-and-qa 或 publish-weekly-report。长期来看,这比每次把同一段流程提示词粘贴进对话更稳。
Prompt Library
建议提示词
设置分析环境
I am a data analyst working in this repo.
Read `AGENTS.md`, check whether a Python environment already exists, and set up the smallest reproducible analysis workflow for this project.
Requirements:
- Prefer `uv` and a local `.venv` unless the repo already standardizes something else.
- Create clear folders for raw data, processed data, notebooks, and outputs.
- Explain how you will run Python, install packages, and save artifacts.
- Do not touch the raw data files. 加载数据集并解释
Please load the dataset at [path] and explain what it is.
Include:
- what each file appears to contain
- likely identifiers, target columns, and date columns
- file formats and encodings
- obvious data quality issues or missing metadata
Do not draw conclusions yet. Start with inventory and interpretation. 先 profile merge 再连接
We need to merge these two datasets, but the primary key is not obvious.
Tasks:
- profile candidate join keys
- show uniqueness and null rates for each candidate
- standardize obvious formatting issues
- run small trial joins and report match rates
- recommend the safest merge strategy before changing any files 打开独立探索 worktree
Create a separate worktree for exploratory analysis of highway proximity and property valuation.
In this worktree:
- generate summary tables and charts
- compare homes near the highway vs. farther away
- save charts and a short markdown readout
- keep the diff focused on exploration only 建立可解释的一阶模型
Model whether highway proximity is associated with lower property valuation.
Requirements:
- start with an interpretable baseline
- define target, features, and controls explicitly
- explain leakage risks and exclusions
- report effect size, uncertainty, and major limitations
- save the modeling code and a short results note 打包给利益相关方
Turn this analysis into a stakeholder-ready artifact.
Audience:
- product and operations leaders deciding whether highway-adjacent properties need separate pricing assumptions
Output:
- one short executive summary
- two to four supporting charts
- a caveats section
- either a `.docx`, `.pdf`, or a static report site, whichever fits best
Also tell me which skill would help most for the chosen output. 技术栈
用于导入、profiling、连接、清洗和第一轮图表的稳妥默认选项。
先从可解释基线开始,再考虑更复杂的预测模型。