{"data":{"slug":"github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-conditional-formatting-data-bar-formatting-c022f89030df","title":"Numeric Extraction and Distribution Analysis","summary":"Extract numeric values from string columns with units and generate comprehensive distribution visualizations including histograms, pie charts, bar charts, and cumulative distribution plots to analyze data trends and patterns.","url":"https:\/\/skillshunter.net\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-conditional-formatting-data-bar-formatting-c022f89030df","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-conditional-formatting-data-bar-formatting-c022f89030df","markdown_url":"https:\/\/skillshunter.net\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-conditional-formatting-data-bar-formatting-c022f89030df.md","download_url":"https:\/\/skillshunter.net\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-conditional-formatting-data-bar-formatting-c022f89030df\/download","category":{"slug":"data-research","name":"Data & Research"},"editor_note":"The tool requires a pandas DataFrame with a column containing string values with units (e.g., '100g'). The user must specify the unit string to remove and the target numeric column name. The output includes a high-resolution PNG image of the distribution dashboard.","instructions":"---\nname: numeric-extraction-and-distribution-analysis\ndescription: \"\u4ece\u5e26\u5355\u4f4d\u7684\u5b57\u7b26\u4e32\u5217\u4e2d\u63d0\u53d6\u6570\u503c\u5e76\u6e05\u6d17\uff0c\u751f\u6210\u5305\u542b\u76f4\u65b9\u56fe\u3001\u997c\u56fe\u3001\u6761\u5f62\u56fe\u548c\u7d2f\u79ef\u5206\u5e03\u56fe\u7684\u591a\u7ef4\u5ea6\u7efc\u5408\u5206\u5e03\u53ef\u89c6\u5316\u56fe\u8868\uff0c\u7528\u4e8e\u5c55\u793a\u6570\u636e\u7684\u96c6\u4e2d\u8d8b\u52bf\u4e0e\u5206\u5e03\u7279\u5f81\u3002\"\n---\n\n# Numeric_Extraction_and_Distribution_Analysis\n\n## Skill Steps\n\nStep1 \u4ece\u539f\u59cb\u6570\u636e\u4e2d\u63d0\u53d6\u76ee\u6807\u5217\uff0c\u6e05\u7406\u65e0\u6548\u548c\u7a7a\u503c\u6570\u636e\uff0c\u5e76\u5b89\u5168\u5730\u5c06\u5e26\u5355\u4f4d\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u6570\u503c\u7c7b\u578b\n```python\nimport pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n# \u914d\u7f6e\u4e2d\u82f1\u6587\u5b57\u4f53\uff0c\u907f\u514d\u56fe\u8868\u4e71\u7801\nplt.rcParams['font.sans-serif'] = ['SimHei', 'DejaVu Sans']\nplt.rcParams['axes.unicode_minus'] = False\n\nitem_col = '\u9879\u76ee\u540d\u79f0'  # \u5360\u4f4d\u793a\u4f8b\uff1a\u5206\u7c7b\u6216\u540d\u79f0\u5217\nvalue_col = '\u5e26\u5355\u4f4d\u7684\u6570\u503c'  # \u5360\u4f4d\u793a\u4f8b\uff1a\u9700\u8981\u63d0\u53d6\u6570\u503c\u7684\u539f\u59cb\u5217\nnumeric_col = '\u63d0\u53d6\u6570\u503c'\nunit_str = 'g'  # \u5360\u4f4d\u793a\u4f8b\uff1a\u9700\u8981\u79fb\u9664\u7684\u5355\u4f4d\u5b57\u7b26\u4e32\n\ndef extract_numeric_value(val_str):\n    \"\"\"\u4ece\u5e26\u5355\u4f4d\u7684\u5b57\u7b26\u4e32\u4e2d\u63d0\u53d6\u6570\u503c\"\"\"\n    if pd.isna(val_str):\n        return None\n    try:\n        # \u79fb\u9664\u5355\u4f4d\u5e76\u8f6c\u6362\u4e3a\u6d6e\u70b9\u6570\n        return float(str(val_str).replace(unit_str, '').strip())\n    except ValueError:\n        return None\n\n# \u6e05\u7406\u7f3a\u5931\u503c\u4e0e\u5f02\u5e38\u5360\u4f4d\u7b26\ndf_clean = df.dropna(subset=[item_col, value_col]).copy()\ndf_clean = df_clean[df_clean[item_col] != '...']\n\n# \u5e94\u7528\u63d0\u53d6\u51fd\u6570\u5e76\u8fc7\u6ee4\u8f6c\u6362\u5931\u8d25\u7684\u884c\ndf_clean[numeric_col] = df_clean[value_col].apply(extract_numeric_value)\ndf_clean = df_clean.dropna(subset=[numeric_col])\n```\n\nStep2 \u521b\u5efa\u57fa\u7840\u5206\u5e03\u76f4\u65b9\u56fe\uff0c\u5e76\u6dfb\u52a0\u5e73\u5747\u503c\u548c\u4e2d\u4f4d\u6570\u7684\u53c2\u8003\u7ebf\u4ee5\u5c55\u793a\u6570\u636e\u7684\u96c6\u4e2d\u8d8b\u52bf\n```python\nplt.figure(figsize=(12, 8))\n\n# \u7ed8\u5236\u76f4\u65b9\u56fe\nplt.hist(df_clean[numeric_col], bins=10, alpha=0.7, color='skyblue', edgecolor='black')\n\n# \u8ba1\u7b97\u5e76\u6dfb\u52a0\u5e73\u5747\u503c\u548c\u4e2d\u4f4d\u6570\u53c2\u8003\u7ebf\nmean_val = df_clean[numeric_col].mean()\nmedian_val = df_clean[numeric_col].median()\nplt.axvline(mean_val, color='red', linestyle='--', linewidth=2, label=f'\u5e73\u5747\u503c: {mean_val:.2f}')\nplt.axvline(median_val, color='green', linestyle='--', linewidth=2, label=f'\u4e2d\u4f4d\u6570: {median_val:.2f}')\n\nplt.xlabel(f'{numeric_col}', fontsize=12)\nplt.ylabel('\u9891\u6570', fontsize=12)\nplt.title(f'{numeric_col}\u5206\u5e03\u76f4\u65b9\u56fe', fontsize=14, fontweight='bold')\nplt.legend()\nplt.grid(True, alpha=0.3)\nplt.show()\n```\n\nStep3 \u751f\u6210\u5305\u542b\u76f4\u65b9\u56fe\u3001\u997c\u56fe\u3001\u6761\u5f62\u56fe\u548c\u7d2f\u79ef\u5206\u5e03\u56fe\u7684\u7efc\u5408\u5206\u6790\u9762\u677f\uff0c\u5168\u9762\u5c55\u793a\u6570\u503c\u7684\u5206\u5e03\u7279\u5f81\u5e76\u4fdd\u5b58\u9ad8\u5206\u8fa8\u7387\u56fe\u7247\n```python\n# \u521b\u5efa 2x2 \u5b50\u56fe\u5e03\u5c40\nfig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, figsize=(16, 12))\n\n# 1. \u76f4\u65b9\u56fe\nax1.hist(df_clean[numeric_col], bins=8, alpha=0.7, color='lightblue', edgecolor='black', rwidth=0.8)\nax1.set_xlabel(f'{numeric_col}', fontsize=12)\nax1.set_ylabel('\u9891\u6570', fontsize=12)\nax1.set_title(f'{numeric_col}\u5206\u5e03\u76f4\u65b9\u56fe', fontsize=14, fontweight='bold')\nax1.grid(True, alpha=0.3)\n\n# 2. \u997c\u56fe (\u57fa\u4e8e value_counts \u7edf\u8ba1\u5360\u6bd4)\nval_counts = df_clean[numeric_col].value_counts().sort_index()\ncolors = plt.cm.Set3(np.linspace(0, 1, len(val_counts)))\nax2.pie(val_counts.values, labels=[f'{x}' for x in val_counts.index], autopct='%1.1f%%', colors=colors, startangle=90)\nax2.set_title(f'{numeric_col}\u5360\u6bd4\u5206\u5e03', fontsize=14, fontweight='bold')\n\n# 3. \u6761\u5f62\u56fe\nval_counts.plot(kind='bar', ax=ax3, color='lightcoral', alpha=0.8)\nax3.set_xlabel(f'{numeric_col}', fontsize=12)\nax3.set_ylabel('\u6570\u91cf', fontsize=12)\nax3.set_title(f'\u5404{numeric_col}\u5bf9\u5e94\u7684\u6570\u91cf', fontsize=14, fontweight='bold')\nax3.tick_params(axis='x', rotation=45)\nax3.grid(True, alpha=0.3)\n\n# 4. \u7d2f\u79ef\u5206\u5e03\u56fe\nsorted_values = np.sort(df_clean[numeric_col])\ncumulative_freq = np.arange(1, len(sorted_values) + 1) \/ len(sorted_values) * 100\nax4.plot(sorted_values, cumulative_freq, marker='o', linewidth=2, markersize=6, color='darkgreen')\nax4.set_xlabel(f'{numeric_col}', fontsize=12)\nax4.set_ylabel('\u7d2f\u79ef\u767e\u5206\u6bd4 (%)', fontsize=12)\nax4.set_title(f'{numeric_col}\u7d2f\u79ef\u5206\u5e03', fontsize=14, fontweight='bold')\nax4.grid(True, alpha=0.3)\n\n# \u8c03\u6574\u5e03\u5c40\u5e76\u4fdd\u5b58\nplt.tight_layout()\noutput_path = 'distribution_dashboard.png'\nplt.savefig(output_path, dpi=300, bbox_inches='tight')\nplt.show()\n```\n","use_cases":["Analyzing product weight data from a dataset with unit strings.","Visualizing sales figures with unit labels for trend analysis.","Assessing customer satisfaction scores with unit-based data."],"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-conditional-formatting\/data-bar-formatting\/SKILL.md","source_commit":"07e7ff8c4bdfd7b79e7402fe94af59d2a5a9749b","license":null,"version":null,"listing_approved_at":"2026-11-16","created_at":"2026-11-15T07:42:24.000000Z","updated_at":"2026-11-16T05:16:30.000000Z","seo_title":"Numeric Extraction and Distribution Analysis Tool","seo_description":"Extract numeric values from string columns with units and generate comprehensive distribution visualizations to analyze data trends and patterns.","seo_keywords":["numeric extraction tool","distribution analysis","data visualization tool","unit string conversion","data trend analysis"]}}