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

excel-basic-statistics-and-routing

Calculate averages for selected groups in Excel and sum items extracted from specified row ranges after removing duplicates. Save filtered records, summary statistics, and item totals as Excel files with local download links.

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

원문원문 설명 보기

对多Sheet Excel文件进行基础统计与,支持按条件筛选计算均值,以及从指定行区间提取数据去重求和,并生成结果文件与下载链接。

연동 도구Excel
설치 방법 보기

이럴 때 유용합니다

  • Calculate average scores for a selected class
  • Sum equipment power values without duplicate items
  • Export filtered records and summary statistics

포함된 파일(1)

  • SKILL.md3.8 KB

SKILL.md(원문)

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

Skill Steps

This sub-skill covers one capability of the Excel workflow. For reading/counting/Parquet optimization, see the parent workflow SKILL.md.

Step1 筛选指定分组数据,将目标列转换为数值类型并计算平均值。

group_col = '班级'  # 占位示例
target_group_value = '358'  # 占位示例
target_cols = ['总分', '理数']  # 占位示例

if group_col not in df_analysis.columns:
    raise ValueError(f"数据中缺少'{group_col}'列。")
df_analysis[group_col] = df_analysis[group_col].astype(str)
filtered_df = df_analysis[df_analysis[group_col] == target_group_value]

avg_scores = {}
for col in target_cols:
    if col not in filtered_df.columns:
        raise ValueError(f"数据中缺少'{col}'列。")
    try:
        filtered_df[col] = pd.to_numeric(filtered_df[col], errors='raise')
        avg_scores[f'平均{col}'] = filtered_df[col].mean()
    except Exception as e:
        raise ValueError(f"列'{col}'无法转换为数值类型: {str(e)}")

output("筛选结果统计: " + str(avg_scores))

Step2 对于小文件,从特定 Sheet 的指定行区间提取目标字段,去重后计算总和。

unique_components = {}
total_power = 0

if total_rows < 10000:
    target_sheet = 'Sheet2'  # 占位示例
    df_sheet2 = pd.read_excel(file_path, sheet_name=target_sheet)
    extracted_data = []
    
    # 提取区间1 (例如 21-28行)
    for i in range(21, 29):
        if i < len(df_sheet2):
            row = df_sheet2.iloc[i]
            component = row.iloc[0]
            power = row.iloc[6]
            if pd.notna(component) and pd.notna(power):
                try:
                    extracted_data.append({'Component': component, 'Value': float(power)})
                except:
                    pass
    
    # 提取区间2 (例如 51-58行)
    for i in range(51, 59):
        if i < len(df_sheet2):
            row = df_sheet2.iloc[i]
            component = row.iloc[0]
            power = row.iloc[1]
            if pd.notna(component) and pd.notna(power):
                try:
                    extracted_data.append({'Component': component, 'Value': float(power)})
                except:
                    pass
    
    # 合并并去重 (保留首次出现的值)
    for item in extracted_data:
        name = item['Component']
        val = item['Value']
        if name not in unique_components:
            unique_components[name] = val
    
    total_power = sum(unique_components.values())

Step3 将计算结果、筛选数据和统计信息保存为Excel文件,并生成本地下载链接。

import os

# 保存区间提取与汇总结果
if total_rows < 10000:
    result_df = pd.DataFrame([
        {'Component Name': name, 'Est. Power (kW)': power} 
        for name, power in unique_components.items()
    ])
    total_row = pd.DataFrame([{'Component Name': '合计', 'Est. Power (kW)': total_power}])
    result_df = pd.concat([result_df, total_row], ignore_index=True)
    
    output_path_power = "output_power_sum.xlsx"
    result_df.to_excel(output_path_power, index=False)
    output(f"功率计算结果已保存。下载链接: file://{os.path.abspath(output_path_power)}")

# 保存筛选与统计结果
output_path_analysis = "output_analysis_result.xlsx"
with pd.ExcelWriter(output_path_analysis, engine='openpyxl') as writer:
    filtered_df.to_excel(writer, sheet_name="筛选数据", index=False)
    pd.DataFrame([avg_scores]).to_excel(writer, sheet_name="统计信息", index=False)

output(f"分析完成,结果已保存。下载链接: file://{os.path.abspath(output_path_analysis)}")

리뷰

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

댓글

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

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

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. 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.8천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.8천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.8천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.8천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.8천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.8천2026년 10월 9일 업데이트

OpenSenseNova의 스킬 모두 보기

이 스킬의 문제 신고