{"data":{"slug":"github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-data-statistics-basic-statistics-c57fd15e7c0e","title":"Excel Basic Statistics and Filtering Analysis","summary":"Perform basic statistics and filtering analysis on multi-sheet Excel files, supporting conditional filtering to calculate averages, extracting data from specified row ranges to deduplicate and sum, and generating result files with download links.","url":"https:\/\/skillshunter.net\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-data-statistics-basic-statistics-c57fd15e7c0e","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-data-statistics-basic-statistics-c57fd15e7c0e","markdown_url":"https:\/\/skillshunter.net\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-data-statistics-basic-statistics-c57fd15e7c0e.md","download_url":"https:\/\/skillshunter.net\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-data-statistics-basic-statistics-c57fd15e7c0e\/download","category":{"slug":"data-research","name":"Data & Research"},"editor_note":"The tool requires the input of a specific column for grouping (e.g., '\u73ed\u7ea7') and a target value for filtering (e.g., '358'). It also needs the target columns for calculation (e.g., '\u603b\u5206', '\u7406\u6570').","instructions":"---\nname: excel-basic-statistics-and-routing\ndescription: \"\u5bf9\u591aSheet Excel\u6587\u4ef6\u8fdb\u884c\u57fa\u7840\u7edf\u8ba1\u4e0e\uff0c\u652f\u6301\u6309\u6761\u4ef6\u7b5b\u9009\u8ba1\u7b97\u5747\u503c\uff0c\u4ee5\u53ca\u4ece\u6307\u5b9a\u884c\u533a\u95f4\u63d0\u53d6\u6570\u636e\u53bb\u91cd\u6c42\u548c\uff0c\u5e76\u751f\u6210\u7ed3\u679c\u6587\u4ef6\u4e0e\u4e0b\u8f7d\u94fe\u63a5\u3002\"\n---\n\n## Skill Steps\n\n> This sub-skill covers one capability of the Excel workflow. For reading\/counting\/Parquet optimization, see the parent workflow SKILL.md.\n\nStep1 \u7b5b\u9009\u6307\u5b9a\u5206\u7ec4\u6570\u636e\uff0c\u5c06\u76ee\u6807\u5217\u8f6c\u6362\u4e3a\u6570\u503c\u7c7b\u578b\u5e76\u8ba1\u7b97\u5e73\u5747\u503c\u3002\n```python\ngroup_col = '\u73ed\u7ea7'  # \u5360\u4f4d\u793a\u4f8b\ntarget_group_value = '358'  # \u5360\u4f4d\u793a\u4f8b\ntarget_cols = ['\u603b\u5206', '\u7406\u6570']  # \u5360\u4f4d\u793a\u4f8b\n\nif group_col not in df_analysis.columns:\n    raise ValueError(f\"\u6570\u636e\u4e2d\u7f3a\u5c11'{group_col}'\u5217\u3002\")\ndf_analysis[group_col] = df_analysis[group_col].astype(str)\nfiltered_df = df_analysis[df_analysis[group_col] == target_group_value]\n\navg_scores = {}\nfor col in target_cols:\n    if col not in filtered_df.columns:\n        raise ValueError(f\"\u6570\u636e\u4e2d\u7f3a\u5c11'{col}'\u5217\u3002\")\n    try:\n        filtered_df[col] = pd.to_numeric(filtered_df[col], errors='raise')\n        avg_scores[f'\u5e73\u5747{col}'] = filtered_df[col].mean()\n    except Exception as e:\n        raise ValueError(f\"\u5217'{col}'\u65e0\u6cd5\u8f6c\u6362\u4e3a\u6570\u503c\u7c7b\u578b: {str(e)}\")\n\noutput(\"\u7b5b\u9009\u7ed3\u679c\u7edf\u8ba1: \" + str(avg_scores))\n```\n\nStep2 \u5bf9\u4e8e\u5c0f\u6587\u4ef6\uff0c\u4ece\u7279\u5b9a Sheet \u7684\u6307\u5b9a\u884c\u533a\u95f4\u63d0\u53d6\u76ee\u6807\u5b57\u6bb5\uff0c\u53bb\u91cd\u540e\u8ba1\u7b97\u603b\u548c\u3002\n```python\nunique_components = {}\ntotal_power = 0\n\nif total_rows < 10000:\n    target_sheet = 'Sheet2'  # \u5360\u4f4d\u793a\u4f8b\n    df_sheet2 = pd.read_excel(file_path, sheet_name=target_sheet)\n    extracted_data = []\n    \n    # \u63d0\u53d6\u533a\u95f41 (\u4f8b\u5982 21-28\u884c)\n    for i in range(21, 29):\n        if i < len(df_sheet2):\n            row = df_sheet2.iloc[i]\n            component = row.iloc[0]\n            power = row.iloc[6]\n            if pd.notna(component) and pd.notna(power):\n                try:\n                    extracted_data.append({'Component': component, 'Value': float(power)})\n                except:\n                    pass\n    \n    # \u63d0\u53d6\u533a\u95f42 (\u4f8b\u5982 51-58\u884c)\n    for i in range(51, 59):\n        if i < len(df_sheet2):\n            row = df_sheet2.iloc[i]\n            component = row.iloc[0]\n            power = row.iloc[1]\n            if pd.notna(component) and pd.notna(power):\n                try:\n                    extracted_data.append({'Component': component, 'Value': float(power)})\n                except:\n                    pass\n    \n    # \u5408\u5e76\u5e76\u53bb\u91cd (\u4fdd\u7559\u9996\u6b21\u51fa\u73b0\u7684\u503c)\n    for item in extracted_data:\n        name = item['Component']\n        val = item['Value']\n        if name not in unique_components:\n            unique_components[name] = val\n    \n    total_power = sum(unique_components.values())\n```\n\nStep3 \u5c06\u8ba1\u7b97\u7ed3\u679c\u3001\u7b5b\u9009\u6570\u636e\u548c\u7edf\u8ba1\u4fe1\u606f\u4fdd\u5b58\u4e3aExcel\u6587\u4ef6\uff0c\u5e76\u751f\u6210\u672c\u5730\u4e0b\u8f7d\u94fe\u63a5\u3002\n```python\nimport os\n\n# \u4fdd\u5b58\u533a\u95f4\u63d0\u53d6\u4e0e\u6c47\u603b\u7ed3\u679c\nif total_rows < 10000:\n    result_df = pd.DataFrame([\n        {'Component Name': name, 'Est. Power (kW)': power} \n        for name, power in unique_components.items()\n    ])\n    total_row = pd.DataFrame([{'Component Name': '\u5408\u8ba1', 'Est. Power (kW)': total_power}])\n    result_df = pd.concat([result_df, total_row], ignore_index=True)\n    \n    output_path_power = \"output_power_sum.xlsx\"\n    result_df.to_excel(output_path_power, index=False)\n    output(f\"\u529f\u7387\u8ba1\u7b97\u7ed3\u679c\u5df2\u4fdd\u5b58\u3002\u4e0b\u8f7d\u94fe\u63a5: file:\/\/{os.path.abspath(output_path_power)}\")\n\n# \u4fdd\u5b58\u7b5b\u9009\u4e0e\u7edf\u8ba1\u7ed3\u679c\noutput_path_analysis = \"output_analysis_result.xlsx\"\nwith pd.ExcelWriter(output_path_analysis, engine='openpyxl') as writer:\n    filtered_df.to_excel(writer, sheet_name=\"\u7b5b\u9009\u6570\u636e\", index=False)\n    pd.DataFrame([avg_scores]).to_excel(writer, sheet_name=\"\u7edf\u8ba1\u4fe1\u606f\", index=False)\n\noutput(f\"\u5206\u6790\u5b8c\u6210\uff0c\u7ed3\u679c\u5df2\u4fdd\u5b58\u3002\u4e0b\u8f7d\u94fe\u63a5: file:\/\/{os.path.abspath(output_path_analysis)}\")\n```\n","use_cases":["Filter class scores and calculate average scores","Extract data from specified row ranges and deduplicate to sum","Generate statistical result files and provide download links"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/OpenSenseNova\/SenseNova-Skills\/blob\/07e7ff8c4bdfd7b79e7402fe94af59d2a5a9749b\/skills\/sn-da-excel-workflow\/capability\/excel-data-statistics\/basic-statistics\/SKILL.md","source_commit":"07e7ff8c4bdfd7b79e7402fe94af59d2a5a9749b","license":null,"version":null,"listing_approved_at":"2026-11-16","created_at":"2026-11-15T08:27:45.000000Z","updated_at":"2026-11-16T05:16:30.000000Z","seo_title":"Excel Basic Statistics and Filtering Analysis Tool","seo_description":"Perform basic statistics and filtering analysis on multi-sheet Excel files, supporting conditional filtering to calculate averages, and extracting data from specified row","seo_keywords":["Excel basic statistics","data filtering analysis","Excel filtering calculation","data deduplication and sum","Excel result download"]}}