Install
openclaw skills install @petehuax/excel-data-cleanerThis skill should be used when the user provides a raw spreadsheet or CSV and needs data cleaning and statistics. Trigger phrases include '数据清洗', '去重补空', '异常值处理', 'Excel 清洗', '透视统计', '这份表帮我整理分析一下'. It profiles the data, applies deterministic cleaning via script (deduplication, missing value handling, outlier detection), and produces a cleaned file plus a statistics report with conclusions.
openclaw skills install @petehuax/excel-data-cleaner输入原始数据表,完成「体检 → 清洗 → 统计 → 结论」一条龙。清洗交给脚本做(确定性、可复现),解读与结论由模型做。核心原则:清洗前先看体检报告再决定策略,不做无声的数据改写。
脚本需要 pandas 与 openpyxl:
pip install pandas openpyxl
# 国内网络建议走镜像,pypi.org 可能极慢:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pandas openpyxl
兼容性:已在 pandas 3.0.6 / openpyxl 3.1.5 实测通过(CSV 与 xlsx 两条读写路径)。脚本内部对文本列的判断同时兼容 pandas 2.x 的 object dtype 与 pandas 3.x 的 str dtype。
# 仅体检,不写文件
python scripts/clean_excel.py 原始数据.xlsx
# 完整清洗:去重 + 数值列中位数填充 + IQR 异常值标记
python scripts/clean_excel.py 原始数据.xlsx \
--sheet Sheet1 \
--out 清洗结果.xlsx \
--dedupe --subset 订单号 \
--numeric-fill median \
--outlier iqr --outlier-action flag \
--report 清洗报告.md
常用参数:
| 参数 | 说明 |
|---|---|
--sheet | 工作表名称,默认第一个 |
--out | 清洗结果输出路径 |
--dedupe | 删除完全重复行 |
--subset | 判重依据列,逗号分隔(如订单号) |
--numeric-fill | mean / median / zero / none |
--text-fill | 文本缺失填充值,默认「未知」 |
--drop-row-na-threshold | 缺失率高于该比例的行直接删除,如 0.5 |
--drop-col-na-threshold | 缺失率高于该比例的列直接删除 |
--outlier | iqr / zscore / none,默认 iqr |
--outlier-action | flag(加一列标记,推荐)/ clip(盖帽)/ drop |
--report | 清洗报告 Markdown 输出路径 |
## 数据体检
- 规模:N 行 × M 列
- 列概览:列名 / 类型 / 缺失率 / 唯一值数 / 示例值
- 完全重复行:X 行
- 疑似异常值:列名 + 数量 + 取值范围
## 清洗记录
1. 删除完全重复行 X 行(剩 Y 行)
2. 「金额」缺失 12 处 → 中位数填充(值=…)
3. 「城市」缺失 3 处 → 填充「未知」
4. 「订单金额」标记异常值 5 条(箱线图法,超出 [Q1-1.5IQR, Q3+1.5IQR])
## 统计分析
- 分组汇总表(维度 + 指标)
- 排名 TOP / BOTTOM
- 环比 / 同比 / 构成占比
## 结论与建议
- 数据说明什么(用业务语言)
- 异常点与需要核实的地方
- 下一步建议
_outlier_列名),让用户自己决定是否剔除。