본문으로 건너뛰기
cccskills
무료GitHub에 공개

single-sheet-reading-and-analysis

Analyze one Excel worksheet by cleaning column names, extracting numbers, and handling gaps from merged cells. Create category counts, percentages, cross-tabulations comparing groups, high-resolution charts, and CSV exports, with Parquet storage for the data.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

원문원문 설명 보기

读取并解析单个Excel工作表数据,支持合并单元格处理、数据清洗、交叉分析及多维度可视化,适用于需要从单表中提取关键指标并进行趋势模拟与图表生成的场景。

연동 도구Excel
설치 방법 보기

이럴 때 유용합니다

  • Clean worksheets containing merged cells
  • Summarize category counts and percentages
  • Compare groups with cross-tabulations
  • Export charts and cleaned data

포함된 파일(1)

  • SKILL.md4.4 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Skill Steps

Step1 导入依赖并配置中英文字体,防止图表乱码

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import re
import base64
from IPython.display import HTML

# 设置中英文字体
plt.rcParams['font.sans-serif'] = ['SimHei', 'DejaVu Sans', 'WenQuanYi Zen Hei']
plt.rcParams['axes.unicode_minus'] = False

Step2 加载数据与基础清洗,包含合并单元格处理与正则提取

def load_and_clean_data(file_path, sheet_name=0):
    # 读取数据
    df = pd.read_excel(file_path, sheet_name=sheet_name)
    
    # 处理合并单元格:向前填充并还原
    # df['group_col'] = df['group_col'].ffill()
    
    # 标准化列名:去除首尾空格及换行符
    df.columns = [str(col).strip().replace('\n', '') for col in df.columns]
    
    # 数据清洗正则表达式示例:提取数值
    if 'target_col' in df.columns:
        df['target_col'] = df['target_col'].astype(str).apply(lambda x: re.sub(r'[^\d.]', '', x))
        df['target_col'] = pd.to_numeric(df['target_col'], errors='coerce')
    
    # 处理全空行缺失值
    df = df.dropna(how='all')
    return df

Step3 数据分类映射与多维度评分/分级算法

def categorize_and_score(df, target_col):
    # 分类映射函数骨架
    def map_category(val):
        if pd.isna(val):
            return '未知'
        elif val > 100:  # 占位示例:高阈值
            return 'A类'
        elif val > 50:   # 占位示例:中阈值
            return 'B类'
        else:
            return 'C类'
    
    if target_col in df.columns:
        df['category'] = df[target_col].apply(map_category)
    
    # 多维度评分/分级算法结构
    # df['score'] = df['metric1'] * 0.4 + df['metric2'] * 0.6
    return df

Step4 交叉分析与统计汇总(频数、占比、总计行)

def analyze_data(df, group_col):
    # value_counts + 占比 + 总计行
    counts = df[group_col].value_counts().reset_index()
    counts.columns = [group_col, '数量']
    counts['占比'] = (counts['数量'] / counts['数量'].sum()).map('{:.2%}'.format)
    
    # 添加总计行
    total_row = pd.DataFrame({
        group_col: ['总计'], 
        '数量': [counts['数量'].sum()], 
        '占比': ['100.00%']
    })
    counts = pd.concat([counts, total_row], ignore_index=True)
    
    # 交叉分析 crosstab/pivot
    if 'category' in df.columns:
        cross_tb = pd.crosstab(df[group_col], df['category'], margins=True, margins_name='总计')
    else:
        cross_tb = None
        
    return counts, cross_tb

Step5 图表美化与高分辨率输出

def visualize_results(df, group_col, target_col, output_path):
    # 设置高分辨率 dpi=300
    fig, ax = plt.subplots(figsize=(10, 6), dpi=300)
    
    # 颜色方案与图表绘制
    valid_data = df.dropna(subset=[group_col, target_col])
    colors = sns.color_palette("husl", len(valid_data[group_col].unique()))
    sns.barplot(data=valid_data, x=group_col, y=target_col, palette=colors, ax=ax)
    
    # 标签位置与美化
    ax.set_title('多维度数据分析', fontsize=16, pad=15)
    ax.set_xlabel('分组维度', fontsize=12)
    ax.set_ylabel('目标指标', fontsize=12)
    plt.xticks(rotation=45, ha='right')
    
    # 添加数据标签
    for p in ax.patches:
        ax.annotate(f'{p.get_height():.1f}', 
                    (p.get_x() + p.get_width() / 2., p.get_height()), 
                    ha='center', va='bottom', fontsize=10)
    
    plt.tight_layout()
    plt.savefig(output_path, dpi=300, bbox_inches='tight')
    plt.close()

Step6 大文件 Parquet 转换与下载链接生成

def export_and_generate_link(df, output_path):
    # 大文件 Parquet 转换
    parquet_path = output_path.replace('.png', '.parquet').replace('.csv', '.parquet')
    df.to_parquet(parquet_path, index=False)
    
    # 下载链接生成
    csv_data = df.to_csv(index=False).encode('utf-8')
    b64 = base64.b64encode(csv_data).decode()
    href = f'<a href="data:file/csv;base64,{b64}" download="analysis_result.csv">点击下载分析结果 (CSV)</a>'
    display(HTML(href))

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Compare counts and shares for two categories in Excel data. The skill cleans the selected columns, calculates differences and percentages, and produces a summary spreadsheet plus bar and pie charts.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Comparing counts for two categories
  • Visualizing category shares
  • Cleaning merged-cell data before counting
OpenSenseNova/SenseNova-Skills5.9천2026년 10월 9일 업데이트

Analyze Excel data using custom categories, count distributions, and compare groups with charts. Score text using its length, technical terms, numbers, and selected complex concepts, then visualize difficulty levels and the relationship between text length and scores.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Summarize Excel records using custom categories
  • Compare category distributions across groups
  • Score and grade text using adjustable rules
OpenSenseNova/SenseNova-Skills5.9천2026년 10월 9일 업데이트

Count categories in a chosen data column after removing missing values and placeholder labels. Calculate each category’s share and create high-resolution charts combining counts, percentages, pie charts, and horizontal bars for distribution reports.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Compare record counts across categories
  • Show category shares with pie and bar charts
  • Exclude placeholder labels before counting
OpenSenseNova/SenseNova-Skills5.9천2026년 10월 9일 업데이트

Clean category and numeric fields in structured data, compare groups with counts and cross-tabulations, and produce charts, Excel results, and a Markdown report. Export visuals as high-resolution PNG and SVG files for use in reports.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Compare category distributions across groups
  • Clean category labels and fill merged-cell gaps
  • Export analysis results to Excel
OpenSenseNova/SenseNova-Skills5.9천2026년 10월 9일 업데이트

Filter Excel data using candidate column names, RGB color values, text prefixes, and regular expressions, which match text patterns. Calculate totals and averages, then export results to Excel with highlighted rows and a download link.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Filtering rows by RGB values or identifier prefixes
  • Converting text to numbers and calculating totals or averages
  • Extracting matching commands with their identifiers and descriptions
OpenSenseNova/SenseNova-Skills5.9천2026년 10월 9일 업데이트

Filter rows from Excel or previously converted Parquet files, a format designed for efficient data storage. Summarize matching records by group with counts, percentages, and totals, then export the summary to Excel.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Count records containing a specified risk level by work category
  • Calculate group shares among matching records
  • Summarize large datasets already converted to Parquet
OpenSenseNova/SenseNova-Skills5.9천2026년 10월 9일 업데이트

OpenSenseNova의 스킬 모두 보기

이 스킬의 문제 신고