/group-by-analysis
对多 Sheet 的 Excel 文件进行行数统计、大文件 Parquet 转换预处理、数据清洗及分组聚合分析,并生成带样式标记的统计表与可视化图表。
$ npx -y skills add OpenSenseNova/SenseNova-Skills --skill group-by-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
/group-by-analysis
Context preview
The summary Claude sees to decide when to auto-load this skill.
对多 Sheet 的 Excel 文件进行行数统计、大文件 Parquet 转换预处理、数据清洗及分组聚合分析,并生成带样式标记的统计表与可视化图表。
SKILL.md
group-by-analysis.SKILL.mdname: group-by-analysis
description: "对多 Sheet 的 Excel 文件进行行数统计、大文件 Parquet 转换预处理、数据清洗及分组聚合分析,并生成带样式标记的统计表与可视化图表。"
Step1 对数据进行清洗与预处理,包括处理合并单元格、正则过滤以及分类映射。
import re
# 1. 处理合并单元格:向前填充
target_col = 'category_column'
df[target_col] = df[target_col].ffill()
# 2. 正则清洗:去除无效字符或筛选特定格式
def clean_text(text):
if pd.isna(text): return text
return re.sub(r'[^\w\s]', '', str(text)).strip()
df[target_col] = df[target_col].apply(clean_text)
# 3. 分类映射函数骨架
def map_categories(value):
mapping = {
'example_key_1': 'Group_A',
'example_key_2': 'Group_B'
}
return mapping.get(value, 'Others')
df['group_tag'] = df[target_col].apply(map_categories)Step2 执行分组统计,计算频数、占比,并添加总计行。
group_col = 'group_tag'
value_col = 'value_column'
# 分组聚合:计数与求和
summary = df.groupby(group_col)[value_col].agg(['count', 'sum']).reset_index()
# 计算占比
total_sum = summary['sum'].sum()
summary['percentage'] = (summary['sum'] / total_sum).map(lambda x: f"{x:.2%}")
# 添加总计行
total_row = pd.DataFrame({
group_col: ['Total'],
'count': [summary['count'].sum()],
'sum': [total_sum],
'percentage': ['100.00%']
})
summary_final = pd.concat([summary, total_row], ignore_index=True)
print(summary_final)Step3 生成可视化柱状图,配置中文字体、数值标签及网格美化。
import matplotlib.pyplot as plt
# 配置中文字体支持
plt.rcParams['font.sans-serif'] = ['SimHei', 'DejaVu Sans']
plt.rcParams['axes.unicode_minus'] = False
plt.figure(figsize=(10, 6), dpi=100)
bars = plt.bar(summary[group_col], summary['sum'], color='#4472C4')
# 添加数值标签
for bar in bars:
height = bar.get_height()
plt.text(bar.get_x() + bar.get_width()/2., height,
f'{height:,.0f}', ha='center', va='bottom', fontsize=10)
plt.title("Distribution Analysis", fontsize=14)
plt.xlabel(group_col)
plt.ylabel("Values")
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.tight_layout()
chart_path = "analysis_chart.png"
plt.savefig(chart_path)Step4 使用 openpyxl 生成带样式和条件格式的 Excel 报告,并提供下载。
from openpyxl import Workbook
from openpyxl.styles import PatternFill, Font, Alignment, Border, Side
output_path = "analysis_report.xlsx"
wb = Workbook()
ws = wb.active
ws.title = "Summary Report"
# 定义样式
header_style = {
"fill": PatternFill(start_color="4472C4", end_color="4472C4", fill_type="solid"),
"font": Font(bold=True, color="FFFFFF"),
"alignment": Alignment(horizontal="center"),
"border": Border(left=Side(style="thin"), right=Side(style="thin"), top=Side(style="thin"), bottom=Side(style="thin"))
}
highlight_style = PatternFill(start_color="00B050", end_color="00B050", fill_type="solid")
# 写入数据并应用样式
for r_idx, row in enumerate(summary_final.values, 2):
for c_idx, value in enumerate(row, 1):
cell = ws.cell(row=r_idx, column=c_idx, value=value)
# 示例:对最大值所在行进行绿色标记
if value == summary['sum'].max():
cell.fill = highlight_style
# 自动调整列宽
for col in ws.columns:
max_length = max(len(str(cell.value)) for cell in col)
ws.column_dimensions[col[0].column_letter].width = max_length + 2
wb.save(output_path)
print(f"Download link: {output_path}")Read more
name: group-by-analysis description: "对多 Sheet 的 Excel 文件进行行数统计、大文件 Parquet 转换预处理、数据清洗及分组聚合分析,并生成带样式标记的统计表与可视化图表。"
Step1 对数据进行清洗与预处理,包括处理合并单元格、正则过滤以及分类映射。
import re
# 1. 处理合并单元格:向前填充
target_col = 'category_column'
df[target_col] = df[target_col].ffill()
# 2. 正则清洗:去除无效字符或筛选特定格式
def clean_text(text):
if pd.isna(text): return text
return re.sub(r'[^\w\s]', '', str(text)).strip()
df[target_col] = df[target_col].apply(clean_text)
# 3. 分类映射函数骨架
def map_categories(value):
mapping = {
'example_key_1': 'Group_A',
'example_key_2': 'Group_B'
}
return mapping.get(value, 'Others')
df['group_tag'] = df[target_col].apply(map_categories)Step2 执行分组统计,计算频数、占比,并添加总计行。
group_col = 'group_tag'
value_col = 'value_column'
# 分组聚合:计数与求和
summary = df.groupby(group_col)[value_col].agg(['count', 'sum']).reset_index()
# 计算占比
total_sum = summary['sum'].sum()
summary['percentage'] = (summary['sum'] / total_sum).map(lambda x: f"{x:.2%}")
# 添加总计行
total_row = pd.DataFrame({
group_col: ['Total'],
'count': [summary['count'].sum()],
'sum': [total_sum],
'percentage': ['100.00%']
})
summary_final = pd.concat([summary, total_row], ignore_index=True)
print(summary_final)Step3 生成可视化柱状图,配置中文字体、数值标签及网格美化。
import matplotlib.pyplot as plt
# 配置中文字体支持
plt.rcParams['font.sans-serif'] = ['SimHei', 'DejaVu Sans']
plt.rcParams['axes.unicode_minus'] = False
plt.figure(figsize=(10, 6), dpi=100)
bars = plt.bar(summary[group_col], summary['sum'], color='#4472C4')
# 添加数值标签
for bar in bars:
height = bar.get_height()
plt.text(bar.get_x() + bar.get_width()/2., height,
f'{height:,.0f}', ha='center', va='bottom', fontsize=10)
plt.title("Distribution Analysis", fontsize=14)
plt.xlabel(group_col)
plt.ylabel("Values")
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.tight_layout()
chart_path = "analysis_chart.png"
plt.savefig(chart_path)Step4 使用 openpyxl 生成带样式和条件格式的 Excel 报告,并提供下载。
from openpyxl import Workbook
from openpyxl.styles import PatternFill, Font, Alignment, Border, Side
output_path = "analysis_report.xlsx"
wb = Workbook()
ws = wb.active
ws.title = "Summary Report"
# 定义样式
header_style = {
"fill": PatternFill(start_color="4472C4", end_color="4472C4", fill_type="solid"),
"font": Font(bold=True, color="FFFFFF"),
"alignment": Alignment(horizontal="center"),
"border": Border(left=Side(style="thin"), right=Side(style="thin"), top=Side(style="thin"), bottom=Side(style="thin"))
}
highlight_style = PatternFill(start_color="00B050", end_color="00B050", fill_type="solid")
# 写入数据并应用样式
for r_idx, row in enumerate(summary_final.values, 2):
for c_idx, value in enumerate(row, 1):
cell = ws.cell(row=r_idx, column=c_idx, value=value)
# 示例:对最大值所在行进行绿色标记
if value == summary['sum'].max():
cell.fill = highlight_style
# 自动调整列宽
for col in ws.columns:
max_length = max(len(str(cell.value)) for cell in col)
ws.column_dimensions[col[0].column_letter].width = max_length + 2
wb.save(output_path)
print(f"Download link: {output_path}")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

