MCPInstall
opensensenova avatar

category-statistics

提取指定类别列并统计各类别数量与占比,生成高分辨率的柱状图、饼图等组合可视化报告,适用于分类数据的分布情况分析。

Installs
0
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/opensensenova/sensenova-skills --skill category-statistics
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads category-statistics automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

Skill Steps

Step1 提取目标类别数据,清洗无效标签,并统计各类别数量与占比。

import pandas as pd

def calculate_distribution(data, target_col='类别'):
    # 检查目标列是否存在
    if target_col not in data.columns:
        raise ValueError(f'未找到指定的类别字段: {target_col}')
    
    # 提取数据,清洗无效标签(如'--'、'代码'等占位符)
    category_data = data[target_col].dropna().replace(['--', '代码'], pd.NA).dropna()
    
    # 统计各类别数量并计算占比
    counts = category_data.value_counts()
    proportions = (counts / counts.sum()) * 100
    
    # 实用技巧:生成包含总计行的统计表
    # summary = counts.copy()
    # summary.loc['总计'] = counts.sum()
    
    return counts, proportions

Step2 生成基础可视化(双轴图:柱状图+占比曲线),并保存为高分辨率图片。

import matplotlib.pyplot as plt

def generate_and_save_basic_chart(counts, proportions, title='各类别数量分布', output_path='category_distribution.png'):
    # 设置中文字体避免乱码
    plt.rcParams['font.sans-serif'] = ['SimHei', 'WenQuanYi Zen Hei', 'Noto Sans CJK JP', 'DejaVu Sans']
    plt.rcParams['axes.unicode_minus'] = False
    
    fig, ax1 = plt.subplots(figsize=(10, 6))
    
    # 绘制柱状图
    bars = ax1.bar(counts.index, counts.values, color='skyblue', edgecolor='black')
    for bar in bars:
        height = bar.get_height()
        ax1.text(bar.get_x() + bar.get_width()/2., height + 0.05, f'{height}', ha='center', va='bottom', fontsize=10)
    
    ax1.set_ylabel('数量', fontsize=12)
    ax1.set_title(title, fontsize=16, fontweight='bold', pad=20)
    
    # 创建第二个y轴显示占比曲线
    ax2 = ax1.twinx()
    ax2.plot(counts.index, proportions.values, color='red', marker='o', linestyle='-', linewidth=2)
    ax2.set_ylabel('占比 (%)', color='red', fontsize=12)
    ax2.tick_params(axis='y', labelcolor='red')
    
    plt.xticks(rotation=45)
    plt.tight_layout()
    
    # 保存高分辨率图表并使用 plt.close() 防止内存泄漏
    fig.savefig(output_path, dpi=300, bbox_inches='tight')
    plt.close(fig)
    
    return output_path

Step3 生成多图组合报告(饼图+柱状图,以及带分类映射的水平柱状图),用于多维度展示。

import matplotlib.pyplot as plt
from matplotlib.patches import Patch

def generate_comprehensive_report(counts, proportions, output_dir='./'):
    plt.rcParams['font.sans-serif'] = ['SimHei', 'WenQuanYi Zen Hei', 'Noto Sans CJK JP', 'DejaVu Sans']
    plt.rcParams['axes.unicode_minus'] = False
    
    # --- 1. 饼图与柱状图组合 ---
    fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(15, 6))
    
    # 饼图
    colors = ['#ff9999', '#66b3ff', '#99ff99', '#ffcc99']
    explode = [0.05] * len(counts) if len(counts) > 0 else None
    wedges, texts, autotexts = ax1.pie(counts.values, labels=counts.index, autopct='%1.1f%%',
                                       colors=colors[:len(counts)], explode=explode, shadow=True, startangle=90)
    ax1.set_title('各类别比例分布', fontsize=14, fontweight='bold')
    for autotext in autotexts:
        autotext.set_color('white')
        autotext.set_fontweight('bold')
    
    # 柱状图
    bars = ax2.bar(range(len(counts)), counts.values, color=colors[:len(counts)], alpha=0.8, edgecolor='black')
    ax2.set_title('各类别数量', fontsize=14, fontweight='bold')
    ax2.set_xticks(range(len(counts)))
    ax2.set_xticklabels(counts.index, rotation=45, ha='right')
    
    for i, bar in enumerate(bars):
        height = bar.get_height()
        ax2.text(bar.get_x() + bar.get_width()/2., height + 0.5, f'{int(height)}\n({proportions.iloc[i]:.1f}%)',
                 ha='center', va='bottom', fontweight='bold')
    
    plt.tight_layout()
    pie_bar_path = f'{output_dir}category_pie_bar.png'
    plt.savefig(pie_bar_path, dpi=300, bbox_inches='tight')
    plt.close(fig)
    
    # --- 2. 水平柱状图 (带分类映射函数骨架与颜色区分) ---
    fig_h, ax_h = plt.subplots(figsize=(12, 8))
    positions = [f'类别{i+1}' for i in range(len(counts))]
    
    # 分类映射示例:根据类别名称包含的关键字动态分配颜色
    bar_colors = ['#66b3ff' if '关键字A' in str(p) else '#ff9999' for p in counts.index]
    bars_h = ax_h.barh(positions, counts.values, color=bar_colors, alpha=0.8, edgecolor='black')
    
    ax_h.set_title('各类别分布详情', fontsize=16, fontweight='bold', pad=20)
    
    for i, (bar, label) in enumerate(zip(bars_h, counts.index)):
        width = bar.get_width()
        # 动态标签示例:提取特定属性
        tag = '类型A' if '关键字A' in str(label) else '其他'
        ax_h.text(width + 0.3, bar.get_y() + bar.get_height()/2, f'{int(width)} ({tag})',
                  ha='left', va='center', fontsize=10)
    
    # 自定义图例
    legend_elements = [Patch(facecolor='#66b3ff', label='类型A组'), Patch(facecolor='#ff9999', label='其他组')]
    ax_h.legend(handles=legend_elements, loc='lower right')
    ax_h.grid(axis='x', alpha=0.3)
    
    plt.tight_layout()
    hbar_path = f'{output_dir}category_hbar.png'
    plt.savefig(hbar_path, dpi=300, bbox_inches='tight')
    plt.close(fig_h)
    
    return [pie_bar_path, hbar_path]

FAQ

What does the category-statistics skill do?

提取指定类别列并统计各类别数量与占比,生成高分辨率的柱状图、饼图等组合可视化报告,适用于分类数据的分布情况分析。

How do I install category-statistics?

Run npx skills add https://github.com/opensensenova/sensenova-skills --skill category-statistics in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/category-statistics/ (personal) or .claude/skills/category-statistics/ (project).

Which AI agents can use category-statistics?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is category-statistics safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains category-statistics?

It is published by opensensenova in opensensenova/sensenova-skills. It has 0 recorded installs.

More from opensensenova/sensenova-skills

View all →
opensensenova avatar

sn-image-base

opensensenova/sensenova-skills

Base-layer skill for the SenseNova-Skills project, providing low-level APIs for image generation, recognition (VLM), and text optimization (LLM). This skill does not preprocess inputs; it only calls backend services and returns results. This skill is not user-facing and is intended for upper-layer skills only.

Media & Creative194 installs
opensensenova avatar

sn-infographic

opensensenova/sensenova-skills

Generates professional infographics with various layout types and visual styles. Analyzes content, recommends layout and style, and generates publication-ready infographics. Use when user asks to create "infographic", "信息图", "visual summary", or "可视化".

Frontend & Design182 installs
opensensenova avatar

sn-ppt-standard

opensensenova/sensenova-skills

仅在 sn-ppt-entry 与 sn-ppt-story 已准备绝对 DECKDIR 和 outline.md 后使用;生成每页独立 HTML(1600×900)、渲染 PNG、逐页讲稿、present.html,并按 staticpostprocess 选择生成由 Standard 自有 exporter 转换的 PPTX。present.html 始终是必交付产物,缺失即技术故障,不得交付;staticpostprocess 含 pptx 时 PPTX 同为必交付产物(缺一即技术故障),且只能由 Standard 自有 exporter 生成;仅当用户明确要求只要 HTML(staticpostprocess 为 [])时,PPTX 才可不交付。

Frontend & Design174 installs
opensensenova avatar

sn-md-to-html-report

opensensenova/sensenova-skills

将 Markdown 报告、研究笔记、行业分析、战略备忘录、技术白皮书、复盘、周报等长文档,重组并创作为有编辑判断、网页美感和证据秩序的自包含 HTML 专题页。用户要求“转成 HTML”“网页化报告”“美化报告”“做成专题页”“便于分享”“提升可读性/设计感”“把报告做成网页”时使用。必须先写 plan.md 再写 HTML,保留原文事实断言和结论强度,不套模板,不做机械 Markdown 转换。

Frontend & Design166 installs
opensensenova avatar

sn-ppt-entry

opensensenova/sensenova-skills

Use when a user asks to create a presentation, slide deck, PPT, or PPTX from a query and optional files, or to resume an existing SenseNova presentation task.

Docs & Writing166 installs
opensensenova avatar

sn-image-resume

opensensenova/sensenova-skills

Generates a designed portfolio-resume image from resume content provided in conversation text. Extracts optional style instructions, converts the resume into a fixed portfolio-resume layout prompt, and generates the final image through sn-image-base. Use when user asks to create "resume image", "portfolio resume", "简历图", "简历海报", or "个人简历视觉设计".

Media & Creative155 installs

Popular other skills

View category →
heygen-com avatar

hyperframes-cli

heygen-com/hyperframes

The HyperFrames CLI by job - scaffold, check, look at frames, edit the timeline, preview, render locally or in the cloud, publish, project history - plus reading its JSON and recovering from build or render failures.

1.7M installs
mattpocock avatar

triage

mattpocock/skills

Move issues and external PRs through a state machine of triage roles, categorise, verify, grill if needed, and write agent-ready briefs.

1.1M installs
mattpocock avatar

ask-matt

mattpocock/skills

Ask which skill or flow fits your situation. A router over the skills in this repo.

881.5K installs
mattpocock avatar

to-questionnaire

mattpocock/skills

Turn a decision you can't fully answer into a questionnaire for someone else to fill in.

609.4K installs
mattpocock avatar

wait-what

mattpocock/skills

Stop. That last message did not land: re-pitch it.

560.9K installs
mattpocock avatar

loop-me

mattpocock/skills

Grill me about specs for the workflows I want to build, within this workspace.

521.7K installs