/comparison-analysis
对两类分类数据进行对比分析,统计数量差异与比例关系并生成可视化图表。
$ npx -y skills add OpenSenseNova/SenseNova-Skills --skill comparison-analysis --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/comparison-analysis
Context preview
The summary Claude sees to decide when to auto-load this skill.
对两类分类数据进行对比分析,统计数量差异与比例关系并生成可视化图表。
SKILL.md
comparison-analysis.SKILL.mdname: categorical-comparison-analysis
description: "对两类分类数据进行对比分析,统计数量差异与比例关系并生成可视化图表。"
categorical-comparison-analysis
> This sub-skill covers one capability of the Excel workflow. For reading/counting/Parquet optimization, see the parent workflow SKILL.md.
Step1 读取文件并统计所有 sheet 的总行数,评估是否需要进行大文件优化处理。
import pandas as pd
from pandas import read_excel
from pathlib import Path
# 统计所有 sheet 的行数以决定处理策略
file_path = "input_data.xlsx"
sheet_names = pd.ExcelFile(file_path).sheet_names
total_rows = 0
for sheet in sheet_names:
# 仅读取行索引以快速计数
df_tmp = read_excel(file_path, sheet_name=sheet, usecols=[0])
total_rows += len(df_tmp)
print(f"Total rows across all sheets: {total_rows}")Step2 提取对比维度的分类信息,执行数据清洗,包括去除空值、处理合并单元格填充以及排除非数据行。
# 定义目标列名
target_col_a = "category_a_column"
target_col_b = "category_b_column"
# 处理合并单元格(ffill)并清洗数据
df[target_col_a] = df[target_col_a].ffill()
df[target_col_b] = df[target_col_b].ffill()
# 排除标题行占位符(如 '代码'、'名称')及空值
exclude_val = "代码"
data_a = df[target_col_a].dropna()
data_a = data_a[data_a != exclude_val]
data_b = df[target_col_b].dropna()
data_b = data_b[data_b != exclude_val]
Step3 统计分类数量,计算差异值与占比,生成多维度对比统计表。
count_a = len(data_a)
count_b = len(data_b)
total_count = count_a + count_b
difference = abs(count_a - count_b)
# 计算占比
ratio_a = (count_a / total_count) * 100 if total_count > 0 else 0
ratio_b = (count_b / total_count) * 100 if total_count > 0 else 0
# 构建统计摘要
summary_df = pd.DataFrame({
"分类名称": ["类别A", "类别B"],
"数量": [count_a, count_b],
"占比": [f"{ratio_a:.2f}%", f"{ratio_b:.2f}%"]
})
print(summary_df)
print(f"数量差异: {difference}")Step4 配置中文字体并生成可视化图表(柱状图与饼图),美化输出效果。
import matplotlib.pyplot as plt
# 中文字体配置
plt.rcParams['font.sans-serif'] = ['SimHei', 'DejaVu Sans']
plt.rcParams['axes.unicode_minus'] = False
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(14, 6))
labels = ['类别A', '类别B']
counts = [count_a, count_b]
colors = ['#3498db', '#e74c3c']
# 柱状图美化
bars = ax1.bar(labels, counts, color=colors, alpha=0.8, edgecolor='black')
ax1.set_title('分类数量对比', fontsize=14)
ax1.grid(axis='y', linestyle='--', alpha=0.6)
for bar in bars:
height = bar.get_height()
ax1.text(bar.get_x() + bar.get_width()/2., height + 0.1, f'{int(height)}',
ha='center', va='bottom', fontweight='bold')
# 饼图美化
ax2.pie(counts, labels=labels, colors=colors, autopct='%1.1f%%', startangle=140, explode=(0.05, 0))
ax2.set_title('分类比例分布', fontsize=14)
output_img = "/mnt/data/comparison_analysis_chart.png"
plt.tight_layout()
plt.savefig(output_img, dpi=300, bbox_inches='tight')
plt.show()Step5 将分析结果导出为 Excel 文件,并生成可供下载的链接。
from IPython.display import FileLink
output_path = "/mnt/data/analysis_report.xlsx"
with pd.ExcelWriter(output_path) as writer:
summary_df.to_excel(writer, sheet_name='统计摘要', index=False)
# 如果有明细数据也可在此导出
print(f"分析报告已生成")
display(FileLink(output_path, result_html_prefix="下载分析报告: "))Read more
name: categorical-comparison-analysis description: "对两类分类数据进行对比分析,统计数量差异与比例关系并生成可视化图表。"
categorical-comparison-analysis
> This sub-skill covers one capability of the Excel workflow. For reading/counting/Parquet optimization, see the parent workflow SKILL.md.
Step1 读取文件并统计所有 sheet 的总行数,评估是否需要进行大文件优化处理。
import pandas as pd
from pandas import read_excel
from pathlib import Path
# 统计所有 sheet 的行数以决定处理策略
file_path = "input_data.xlsx"
sheet_names = pd.ExcelFile(file_path).sheet_names
total_rows = 0
for sheet in sheet_names:
# 仅读取行索引以快速计数
df_tmp = read_excel(file_path, sheet_name=sheet, usecols=[0])
total_rows += len(df_tmp)
print(f"Total rows across all sheets: {total_rows}")Step2 提取对比维度的分类信息,执行数据清洗,包括去除空值、处理合并单元格填充以及排除非数据行。
# 定义目标列名 target_col_a = "category_a_column" target_col_b = "category_b_column" # 处理合并单元格(ffill)并清洗数据 df[target_col_a] = df[target_col_a].ffill() df[target_col_b] = df[target_col_b].ffill() # 排除标题行占位符(如 '代码'、'名称')及空值 exclude_val = "代码" data_a = df[target_col_a].dropna() data_a = data_a[data_a != exclude_val] data_b = df[target_col_b].dropna() data_b = data_b[data_b != exclude_val]
Step3 统计分类数量,计算差异值与占比,生成多维度对比统计表。
count_a = len(data_a)
count_b = len(data_b)
total_count = count_a + count_b
difference = abs(count_a - count_b)
# 计算占比
ratio_a = (count_a / total_count) * 100 if total_count > 0 else 0
ratio_b = (count_b / total_count) * 100 if total_count > 0 else 0
# 构建统计摘要
summary_df = pd.DataFrame({
"分类名称": ["类别A", "类别B"],
"数量": [count_a, count_b],
"占比": [f"{ratio_a:.2f}%", f"{ratio_b:.2f}%"]
})
print(summary_df)
print(f"数量差异: {difference}")Step4 配置中文字体并生成可视化图表(柱状图与饼图),美化输出效果。
import matplotlib.pyplot as plt
# 中文字体配置
plt.rcParams['font.sans-serif'] = ['SimHei', 'DejaVu Sans']
plt.rcParams['axes.unicode_minus'] = False
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(14, 6))
labels = ['类别A', '类别B']
counts = [count_a, count_b]
colors = ['#3498db', '#e74c3c']
# 柱状图美化
bars = ax1.bar(labels, counts, color=colors, alpha=0.8, edgecolor='black')
ax1.set_title('分类数量对比', fontsize=14)
ax1.grid(axis='y', linestyle='--', alpha=0.6)
for bar in bars:
height = bar.get_height()
ax1.text(bar.get_x() + bar.get_width()/2., height + 0.1, f'{int(height)}',
ha='center', va='bottom', fontweight='bold')
# 饼图美化
ax2.pie(counts, labels=labels, colors=colors, autopct='%1.1f%%', startangle=140, explode=(0.05, 0))
ax2.set_title('分类比例分布', fontsize=14)
output_img = "/mnt/data/comparison_analysis_chart.png"
plt.tight_layout()
plt.savefig(output_img, dpi=300, bbox_inches='tight')
plt.show()Step5 将分析结果导出为 Excel 文件,并生成可供下载的链接。
from IPython.display import FileLink
output_path = "/mnt/data/analysis_report.xlsx"
with pd.ExcelWriter(output_path) as writer:
summary_df.to_excel(writer, sheet_name='统计摘要', index=False)
# 如果有明细数据也可在此导出
print(f"分析报告已生成")
display(FileLink(output_path, result_html_prefix="下载分析报告: "))The SenseNova model family plugs directly into agent runtimes such as OpenClaw and hermes-agent, with the skills in this repository extending the models with concrete, end-to-end office capabilities.
Repo: OpenSenseNova/SenseNova-Skills
Other skills on sensenova-skills.
- /sn-da-excel-workflow
Excel 数据分析多步编排器。覆盖:(1) 读取多 Sheet Excel 文件并统计行数,(2) 大文件检测(≥10k 行自动 Parquet 优化),(3) 数据清洗(缺失值、文本标准化、无效字符),(4) 条件筛选与分类提取,(5) 跨 Sheet 统计聚合,(6) 导出 Excel/CSV 并提供下载链接。覆盖从数据读取到报告生成全流程,按步骤编排 capability 子 skill。**遇到以下任一情况就主动使用本 skill,不要自行写几行 pandas 就回答**:①用户出现触发词:Excel 分析 / 表格分析 / 数据分析 /
Open skill - /category-coloring
当Excel文件总行数超过1万行时,通过转换为Parquet格式提升读取性能,提取目标指标并计算最大值,最后将结果输出为Excel并对特定行进行高亮标注。
Open skill - /duplicate-value-coloring
对比Excel多表中的特定系数并对异常值进行颜色标记。
Open skill - /outlier-coloring
识别 Excel 中的超限数值与错误单元格并进行高亮标注。
Open skill - /threshold-cell-coloring
根据Excel总行数自动切换Parquet加速读取,计算特定维度的时间序列平均值,并使用openpyxl输出带有条件格式(如低于均值标绿)和自定义样式的分析报告。
Open skill - /top-value-coloring
根据数据规模动态选择处理策略,对多表数据进行合并、统计筛选,并利用 openpyxl 实现关键指标的自动化样式高亮与格式化导出。
Open skill

