{"data":{"slug":"github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-result-export-report-generation-export-6727035a857d","title":"Excel Data Categorization and Statistical Analysis","summary":"Extract data from Excel files, perform categorization and statistical analysis, and generate visual charts and download links.","url":"https:\/\/skillshunter.net\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-result-export-report-generation-export-6727035a857d","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-result-export-report-generation-export-6727035a857d","markdown_url":"https:\/\/skillshunter.net\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-result-export-report-generation-export-6727035a857d.md","download_url":"https:\/\/skillshunter.net\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-result-export-report-generation-export-6727035a857d\/download","category":{"slug":"data-research","name":"Data & Research"},"editor_note":"The skill requires a Python environment with pandas and matplotlib installed. The user must provide an Excel file containing the target column for categorization and the grouping column for cross-analysis.","instructions":"---\nname: excel-data-analysis-and-report-generation\ndescription: \"\u4eceExcel\u63d0\u53d6\u591a\u7c7b\u578b\u6570\u636e\uff0c\u5e76\u751f\u6210\u5305\u542b\u53ef\u89c6\u5316\u56fe\u8868\u4e0e\u4e0b\u8f7d\u94fe\u63a5\u7684\u7efc\u5408\u5206\u6790\u62a5\u544a\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 \u57fa\u4e8e\u6307\u5b9a\u5217\u63d0\u53d6\u6709\u6548\u4ee3\u7801\u6216\u8fdb\u884c\u5206\u7c7b\u6620\u5c04\uff0c\u751f\u6210\u5305\u542b\u5360\u6bd4\u4e0e\u603b\u8ba1\u884c\u7684\u7edf\u8ba1\u8868\uff0c\u5e76\u652f\u6301\u4ea4\u53c9\u5206\u6790\u3002\n```python\n# \u5206\u7c7b\u6620\u5c04\u51fd\u6570\u9aa8\u67b6\ndef categorize_item(item_name):\n    category_a_keywords = ['keyword1', 'keyword2'] # \u5360\u4f4d\u793a\u4f8b\n    if pd.isna(item_name):\n        return '\u672a\u77e5'\n    if any(kw in str(item_name) for kw in category_a_keywords):\n        return '\u7c7b\u522bA'\n    return '\u5176\u4ed6'\n\ntarget_col = '\u9879\u76ee\u540d\u79f0' # \u66ff\u6362\u4e3a\u5b9e\u9645\u5217\u540d\ngroup_col = '\u6240\u5c5e\u533a\u57df'  # \u66ff\u6362\u4e3a\u5b9e\u9645\u5206\u7ec4\u5217\u540d\n\nif target_col in combined_df.columns:\n    combined_df['\u5206\u7c7b'] = combined_df[target_col].apply(categorize_item)\n    \n    # value_counts + \u5360\u6bd4 + \u603b\u8ba1\u884c\n    category_counts = combined_df['\u5206\u7c7b'].value_counts().reset_index()\n    category_counts.columns = ['\u7c7b\u522b', '\u6570\u91cf']\n    total = category_counts['\u6570\u91cf'].sum()\n    category_counts['\u5360\u6bd4'] = (category_counts['\u6570\u91cf'] \/ total).apply(lambda x: f'{x:.2%}')\n    \n    total_row = pd.DataFrame([{'\u7c7b\u522b': '\u603b\u8ba1', '\u6570\u91cf': total, '\u5360\u6bd4': '100.00%'}])\n    category_counts = pd.concat([category_counts, total_row], ignore_index=True)\n    \n    # \u4ea4\u53c9\u5206\u6790 crosstab\n    if group_col in combined_df.columns:\n        cross_tb = pd.crosstab(combined_df[group_col], combined_df['\u5206\u7c7b'], margins=True, margins_name='\u603b\u8ba1')\n        print(\"\u4ea4\u53c9\u5206\u6790\u7ed3\u679c:\\n\", cross_tb)\n```\n\nStep2 \u8bc6\u522b\u76ee\u6807\u503c\u8d85\u8fc7\u9650\u503c\u7684\u884c\uff0c\u57fa\u4e8e\u5173\u952e\u5b57\u5b9a\u4f4d\u5e76\u53cd\u5411\u641c\u7d22\u9650\u503c\u4ee5\u786e\u4fdd\u6570\u636e\u5173\u8054\u3002\n```python\nimport re\n\nexceed_rows = []\ndf_target = combined_df.copy()\n\nfor i, row in df_target.iterrows():\n    if '\u5171\u8ba1' in str(row.iloc[0]):\n        try:\n            target_val = float(row.iloc[8]) # \u76ee\u6807\u503c\u6240\u5728\u5217\u7d22\u5f15\n        except (ValueError, TypeError):\n            continue\n        \n        limit_val = None\n        structure_name = \"\u672a\u77e5\u7ed3\u6784\"\n        \n        # \u53cd\u5411\u641c\u7d22\u9650\u503c\n        for j in range(i-1, max(0, i-15), -1):\n            check_row = df_target.iloc[j, :]\n            check_str = ' '.join([str(x) for x in check_row.values if pd.notna(x)])\n            if '\u9650\u503c' in check_str:\n                # \u6570\u636e\u6e05\u6d17\u6b63\u5219\u8868\u8fbe\u5f0f\n                match = re.search(r'\u9650\u503c([\\d.]+)', check_str)\n                if match:\n                    limit_val = float(match.group(1))\n                    for k in range(j-1, max(0, j-5), -1):\n                        name_row = df_target.iloc[k, 0]\n                        if pd.notna(name_row) and '\u5173\u952e\u5b57' in str(name_row):\n                            structure_name = str(name_row)\n                            break\n                    break\n        \n        # \u591a\u7ef4\u5ea6\u8bc4\u5206\/\u5206\u7ea7\u7b97\u6cd5\u7ed3\u6784\n        if limit_val is not None and target_val > limit_val:\n            severity = '\u9ad8' if (target_val - limit_val) > 10 else '\u4e2d'\n            exceed_rows.append({\n                'row_index': i,\n                'structure_name': structure_name,\n                'target_val': target_val,\n                'limit': limit_val,\n                'exceed_value': target_val - limit_val,\n                'severity': severity\n            })\n```\n\nStep3 \u751f\u6210\u9ad8\u5206\u8fa8\u7387\u53ef\u89c6\u5316\u56fe\u8868\u5c55\u793a\u5206\u7c7b\u5360\u6bd4\uff0c\u4fdd\u5b58\u7edf\u8ba1\u7ed3\u679c\u5e76\u751f\u6210\u6c99\u7bb1\u4e0b\u8f7d\u94fe\u63a5\u3002\n```python\nimport matplotlib.pyplot as plt\nimport matplotlib\n\n# \u4e2d\u82f1\u6587\u5b57\u4f53\u914d\u7f6e\nmatplotlib.rcParams['font.sans-serif'] = ['SimHei', 'DejaVu Sans']\nmatplotlib.rcParams['axes.unicode_minus'] = False\n\n# \u51c6\u5907\u56fe\u8868\u6570\u636e (\u6392\u9664\u603b\u8ba1\u884c)\nplot_data = category_counts[category_counts['\u7c7b\u522b'] != '\u603b\u8ba1']\ncategories = plot_data['\u7c7b\u522b'].tolist()\ncounts = plot_data['\u6570\u91cf'].tolist()\n\n# \u56fe\u8868\u7f8e\u5316\uff08dpi\u3001\u989c\u8272\u65b9\u6848\u3001\u6807\u7b7e\u4f4d\u7f6e\uff09\nfig, ax = plt.subplots(figsize=(10, 8))\ncolors = ['#FF6B6B', '#4ECDC4', '#45B7D1', '#96CEB4', '#F9A826']\nexplode = [0.05] * len(categories)\n\nwedges, texts, autotexts = ax.pie(\n    counts, \n    labels=categories, \n    autopct='%1.1f%%',\n    startangle=90,\n    colors=colors[:len(categories)],\n    explode=explode,\n    shadow=True,\n    textprops={'fontsize': 12}\n)\n\nax.set_title('\u5404\u7c7b\u522b\u6570\u91cf\u5360\u6bd4\u5206\u6790', fontsize=16, fontweight='bold', pad=20)\nax.legend(wedges, categories, title=\"\u7c7b\u522b\", loc=\"center left\", bbox_to_anchor=(1, 0, 0.5, 1))\n\n# \u4fdd\u5b58\u56fe\u8868\nchart_path = os.path.join(output_dir, 'category_analysis.png')\nplt.savefig(chart_path, dpi=150, bbox_inches='tight')\n\n# \u4fdd\u5b58\u7edf\u8ba1\u7ed3\u679c\u5e76\u751f\u6210\u4e0b\u8f7d\u94fe\u63a5\noutput_path = os.path.join(output_dir, 'analysis_result.xlsx')\ncategory_counts.to_excel(output_path, index=False)\n\nprint(f\"\u7edf\u8ba1\u7ed3\u679c\u5df2\u4fdd\u5b58\u81f3: {output_path}\")\nprint(f\"\u4e0b\u8f7d\u94fe\u63a5: [\u4e0b\u8f7d\u7edf\u8ba1\u7ed3\u679c](sandbox:{output_path})\")\nprint(f\"\u56fe\u8868\u4e0b\u8f7d\u94fe\u63a5: [\u4e0b\u8f7d\u56fe\u8868](sandbox:{chart_path})\")\n```\n","use_cases":["Categorize project names in Excel and generate category proportions and total row counts.","Perform cross-analysis to view the distribution of different regions and categories.","Generate visual charts to intuitively display the results of data analysis."],"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-result-export\/report-generation-export\/SKILL.md","source_commit":"07e7ff8c4bdfd7b79e7402fe94af59d2a5a9749b","license":null,"version":null,"listing_approved_at":"2026-11-16","created_at":"2026-11-15T09:49:50.000000Z","updated_at":"2026-11-16T05:16:30.000000Z","seo_title":"Excel Data Categorization and Statistical Analysis Tool","seo_description":"Use Python to perform categorization and statistical analysis on Excel data, generate charts and download links, suitable for data analysis and report generation.","seo_keywords":["Excel data categorization","statistical analysis tool","data visualization charts","Excel report generation","categorization and statistical analysis"]}}