Excel analyzer

From malue-ai/dazee-small · View interactive version

Excel analyzer is an AI agent skill from the GitHub repository malue-ai/dazee-small. Analyze and process Excel/CSV files using pandas and openpyxl. Supports data summary, filtering, pivot tables, and chart generation.

How to use this skill

Skill file

Excel 分析

帮助用户分析和处理 Excel/CSV 文件。

使用场景

依赖安装

首次使用时自动安装:

pip install pandas openpyxl

执行方式

通过 Python 脚本使用 pandas 处理 Excel/CSV 文件。

读取文件

import pandas as pd

# 读取 Excel
df = pd.read_excel("/path/to/file.xlsx", sheet_name=0)

# 读取 CSV
df = pd.read_csv("/path/to/file.csv")

# 查看基本信息
print(f"行数: {len(df)}, 列数: {len(df.columns)}")
print(f"列名: {list(df.columns)}")
print(df.head())

数据汇总

# 基本统计
print(df.describe())

# 按列汇总
print(df.groupby("类别").agg({"金额": ["sum", "mean", "count"]}))

数据筛选

# 条件筛选
filtered = df[df["金额"] > 1000]

# 多条件
filtered = df[(df["部门"] == "销售") & (df["金额"] > 500)]

导出结果

# 导出到新 Excel
result.to_excel("/path/to/output.xlsx", index=False)

# 导出到 CSV
result.to_csv("/path/to/output.csv", index=False, encoding="utf-8-sig")

数据校验(必须执行)

分析前和分析后都要做数据校验,确保结果可信:

清洗后校验

# 1. 行数校验:打印清洗前后行数,确认只去了空行/噪音行
print(f"清洗前: {len(df_raw)} 行 → 清洗后: {len(df_clean)} 行 (去除 {len(df_raw)-len(df_clean)} 行)")

# 2. 分类列去重:检查分类列(如地区、产品)是否有近似重复值
for col in categorical_columns:
    unique_vals = df_clean[col].unique()
    print(f"列 '{col}' 唯一值: {unique_vals}")
    # 检查近似重复(如 "华东" vs "华东地区")
    # 如有近似重复,合并为统一值

# 3. 聚合一致性校验:各分组 sum 必须等于总 sum
total = df_clean["金额"].sum()
group_total = df_clean.groupby("地区")["金额"].sum().sum()
assert abs(total - group_total) < 0.01, f"聚合不一致: 总额 {total} ≠ 分组合计 {group_total}"

报告校验

输出规范

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.