mcpbeat Sign in

Group By Analysis Agent Skill

对多 Sheet 的 Excel 文件进行行数统计、大文件 Parquet 转换预处理、数据清洗及分组聚合分析,并生成带样式标记的统计表与可视化图表。

913 tokens
context cost
the whole folder, loaded on every use
1
files
instructions only
0
copies elsewhere
how many repositories repackaged it
4851
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/OpenSenseNova/SenseNova-Skills --skill group-by-analysis

The instruction itself

as written by the author

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}")

Other skills for the same job

different authors, same section of the catalogue
XLSX
by anthropics
vendor ×15

Comprehensive spreadsheet creation, editing, and analysis with support for formulas, formatting, data analysis, and visualization. When Claude needs to work with spreadsheets (.xlsx, .xlsm, .csv, .tsv, etc) for: (1) Creating new spreadsheets with formulas and formatting, (2) Reading or analyzing data, (3) Modify existing spreadsheets while preserving formulas, (4) Data analysis and visualization in spreadsheets, or (5) Recalculating formulas

5k tokens scripts
XLSX
by w95
×7

Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like \"the xlsx in my downloads\") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.

3k tokens
Raffle Winner Picker
by frostant
×5

Picks random winners from lists, spreadsheets, or Google Sheets for giveaways, raffles, and contests. Ensures fair, unbiased selection with transparency.

949 tokens
Fda Database
by christophacham
×4

Query openFDA API for drugs, devices, adverse events, recalls, regulatory submissions (510k, PMA), substance identification (UNII), for FDA regulatory data analysis and safety research.

32k tokens scripts
Matlab
by christophacham
×4

MATLAB and GNU Octave numerical computing for matrix operations, data analysis, visualization, and scientific computing. Use when writing MATLAB/Octave scripts for linear algebra, signal processing, image processing, differential equations, optimization, statistics, or creating scientific visualizations. Also use when the user needs help with MATLAB syntax, functions, or wants to convert between MATLAB and Python code. Scripts can be executed with MATLAB or the open-source GNU Octave interpreter.

25k tokens
Umap Learn
by ComeOnOliver
×4

UMAP dimensionality reduction. Fast nonlinear manifold learning for 2D/3D visualization, clustering preprocessing (HDBSCAN), supervised/parametric UMAP, for high-dimensional data.

14k tokens
D3 Viz
by chrisvoncsefalvay
×3

Creating interactive data visualisations using d3.js. This skill should be used when creating custom charts, graphs, network diagrams, geographic visualisations, or any complex SVG-based data visualisation that requires fine-grained control over visual elements, transitions, or interactions. Use this for bespoke visualisations beyond standard charting libraries, whether in React, Vue, Svelte, vanilla JavaScript, or any other environment.

20k tokens
Alphafold Database
by christophacham
×3

Access AlphaFold 200M+ AI-predicted protein structures. Retrieve structures by UniProt ID, download PDB/mmCIF files, analyze confidence metrics (pLDDT, PAE), for drug discovery and structural biology.

7k tokens

How to use it

Copy the folder

Take opensensenova/group-by-analysis from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.