对多Sheet Excel文件进行基础统计与,支持按条件筛选计算均值,以及从指定行区间提取数据去重求和,并生成结果文件与下载链接。
npx skills add https://github.com/OpenSenseNova/SenseNova-Skills --skill excel-basic-statistics-and-routing
> 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)}")
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
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.
Picks random winners from lists, spreadsheets, or Google Sheets for giveaways, raffles, and contests. Ensures fair, unbiased selection with transparency.
Query openFDA API for drugs, devices, adverse events, recalls, regulatory submissions (510k, PMA), substance identification (UNII), for FDA regulatory data analysis and safety research.
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.
UMAP dimensionality reduction. Fast nonlinear manifold learning for 2D/3D visualization, clustering preprocessing (HDBSCAN), supervised/parametric UMAP, for high-dimensional data.
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.
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.
Take opensensenova/excel-basic-statistics-and-routing from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
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.