{"data":{"slug":"github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-cell-coloring-outlier-coloring-130b62b970ca","title":"Outlier Coloring","summary":"Identify and highlight outlier values and error cells in Excel for efficient data review.","url":"https:\/\/skillshunter.net\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-cell-coloring-outlier-coloring-130b62b970ca","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-cell-coloring-outlier-coloring-130b62b970ca","markdown_url":"https:\/\/skillshunter.net\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-cell-coloring-outlier-coloring-130b62b970ca.md","download_url":"https:\/\/skillshunter.net\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-cell-coloring-outlier-coloring-130b62b970ca\/download","category":{"slug":"data-research","name":"Data & Research"},"editor_note":"The tool requires a Python environment with pandas and openpyxl installed to process Excel files and apply formatting. It also assumes the target column and value column are correctly specified in the script.","instructions":"---\nname: excel-outlier-detection-and-highlighting\ndescription: \"\u8bc6\u522b Excel \u4e2d\u7684\u8d85\u9650\u6570\u503c\u4e0e\u9519\u8bef\u5355\u5143\u683c\u5e76\u8fdb\u884c\u9ad8\u4eae\u6807\u6ce8\u3002\"\n---\n\n# Outlier_Coloring\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 \u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u63d0\u53d6\u9650\u503c\uff0c\u5e76\u7ed3\u5408\u4e0a\u4e0b\u6587\u903b\u8f91\u8bc6\u522b\u603b\u4f20\u70ed\u7cfb\u6570\u8d85\u9650\u7684\u884c\u3002\n```python\nimport re\n\nexceed_rows = []\ntarget_col = 0  # \u5047\u8bbe\u7279\u5f81\u5217\u5728\u7b2c\u4e00\u5217\nvalue_col = 8   # \u5047\u8bbe\u6570\u503c\u5217\u5728\u7b2c\u4e5d\u5217\n\nfor i, row in df.iterrows():\n    row_str = str(row.iloc[target_col]) if pd.notna(row.iloc[target_col]) else \"\"\n    \n    # \u6b63\u5219\u8868\u8fbe\u5f0f\u7cbe\u51c6\u63d0\u53d6\u9650\u503c\uff0c\u4f8b\u5982 \"\u9650\u503c0.5\"\n    if '\u9650\u503c' in row_str:\n        match = re.search(r'\u9650\u503c([\\d.]+)', row_str)\n        if match:\n            current_limit = float(match.group(1))\n            \n    # \u8bc6\u522b\u8ba1\u7b97\u7ed3\u679c\u884c\u5e76\u8fdb\u884c\u5bf9\u6bd4\n    if '\u5171\u8ba1' in row_str:\n        try:\n            actual_val = float(row.iloc[value_col])\n            # \u5411\u4e0a\u56de\u6eaf\u5bfb\u627e\u7ed3\u6784\u540d\u79f0\uff08\u5b9e\u6218\u6280\u5de7\uff1a\u904d\u5386\u8fd8\u539f\u4e0a\u4e0b\u6587\uff09\n            structure_name = \"\u672a\u77e5\u7ed3\u6784\"\n            for j in range(i-1, max(0, i-15), -1):\n                prev_val = str(df.iloc[j, 0])\n                if any(kw in prev_val for kw in ['\u7cfb\u6570', '\u56f4\u62a4']):\n                    structure_name = prev_val\n                    break\n            \n            # \u63d0\u53d6\u6700\u8fd1\u7684\u9650\u503c\u8fdb\u884c\u5bf9\u6bd4\n            limit_val = None\n            for j in range(i-1, max(0, i-15), -1):\n                check_str = ' '.join([str(x) for x in df.iloc[j, :] if pd.notna(x)])\n                limit_match = re.search(r'\u9650\u503c([\\d.]+)', check_str)\n                if limit_match:\n                    limit_val = float(limit_match.group(1))\n                    break\n            \n            if limit_val and actual_val > limit_val:\n                exceed_rows.append({\n                    'row_index': i,\n                    'name': structure_name,\n                    'value': actual_val,\n                    'limit': limit_val,\n                    'diff': actual_val - limit_val\n                })\n        except (ValueError, TypeError):\n            continue\n```\n\nStep2 \u904d\u5386\u6307\u5b9a Sheet \u67e5\u627e\u5305\u542b '#DIV\/' \u7b49\u5f02\u5e38\u9519\u8bef\u7684\u5355\u5143\u683c\uff0c\u5e76\u8bb0\u5f55\u5750\u6807\u3002\n```python\n# \u9488\u5bf9\u7279\u5b9a Sheet\uff08\u5982 Sheet3\uff09\u68c0\u6d4b\u516c\u5f0f\u9519\u8bef\nws_error = wb['Sheet3']\nerror_cells = []\n\nfor row in ws_error.iter_rows(min_row=1, max_row=ws_error.max_row):\n    for cell in row:\n        if cell.value is not None:\n            val_str = str(cell.value)\n            # \u8bc6\u522b Excel \u9664\u96f6\u9519\u8bef\u6216\u5176\u4ed6\u5f02\u5e38\u6807\u8bc6\n            if '#DIV\/' in val_str:\n                error_cells.append({\n                    'coord': cell.coordinate,\n                    'val': cell.value\n                })\n```\n\nStep3 \u5bf9\u8bc6\u522b\u51fa\u7684\u8d85\u9650\u884c\u548c\u5f02\u5e38\u5355\u5143\u683c\u8fdb\u884c\u7ea2\u8272\u9ad8\u4eae\u6807\u6ce8\uff0c\u5e76\u4fdd\u5b58\u7ed3\u679c\u3002\n```python\nfrom openpyxl.styles import PatternFill\n\n# \u5b9a\u4e49\u7ea2\u8272\u586b\u5145\u6837\u5f0f\nred_fill = PatternFill(start_color='FF0000', end_color='FF0000', fill_type='solid')\n\n# \u6807\u6ce8\u8d85\u9650\u884c\uff08\u6ce8\u610f\uff1aExcel \u884c\u53f7 = pandas \u7d22\u5f15 + 1\uff09\n# \u5047\u8bbe\u5728\u7b2c\u4e00\u4e2a Sheet \u4e2d\u6807\u6ce8\nws_main = wb[wb.sheetnames[0]]\nfor item in exceed_rows:\n    excel_row = item['row_index'] + 1\n    for col in range(1, ws_main.max_column + 1):\n        ws_main.cell(row=excel_row, column=col).fill = red_fill\n\n# \u6807\u6ce8\u5f02\u5e38\u5355\u5143\u683c\nfor err in error_cells:\n    ws_error[err['coord']].fill = red_fill\n\noutput_path = \"highlighted_report.xlsx\"\nwb.save(output_path)\n```\n\nStep4 \u6c47\u603b\u8d85\u9650\u6570\u636e\u751f\u6210\u5206\u6790\u62a5\u544a\uff0c\u5e76\u63d0\u4f9b\u4e0b\u8f7d\u94fe\u63a5\u3002\n```python\n# \u521b\u5efa\u6c47\u603b DataFrame\nsummary_df = pd.DataFrame(exceed_rows)\nif not summary_df.empty:\n    summary_df['Excel\u884c\u53f7'] = summary_df['row_index'] + 1\n    summary_df = summary_df[['Excel\u884c\u53f7', 'name', 'value', 'limit', 'diff']]\n    summary_df.columns = ['\u884c\u53f7', '\u7ed3\u6784\u540d\u79f0', '\u5b9e\u6d4b\u503c', '\u9650\u503c', '\u8d85\u51fa\u503c']\n\nsummary_path = \"outlier_summary.xlsx\"\nsummary_df.to_excel(summary_path, index=False)\n\n# \u8f93\u51fa\u4e0b\u8f7d\u94fe\u63a5\u683c\u5f0f\nprint(f\"\u5904\u7406\u5b8c\u6210\u3002\u7ed3\u679c\u6587\u4ef6\uff1a{output_path}\")\nprint(f\"\u6c47\u603b\u62a5\u544a\uff1a{summary_path}\")\n```\n","use_cases":["Detect and highlight rows in Excel where the total heat transfer coefficient exceeds the specified limit.","Identify and mark cells with division by zero errors in specific sheets."],"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-cell-coloring\/outlier-coloring\/SKILL.md","source_commit":"07e7ff8c4bdfd7b79e7402fe94af59d2a5a9749b","license":null,"version":null,"listing_approved_at":"2026-11-16","created_at":"2026-11-15T07:29:32.000000Z","updated_at":"2026-11-16T05:16:30.000000Z","seo_title":"Excel Outlier Highlighting Tool","seo_description":"Automate the detection and highlighting of outlier values and error cells in Excel for quick data analysis.","seo_keywords":["Excel outlier detection","Excel error cell highlighting","Heat transfer coefficient analysis","Excel formula error detection"]}}