# Excel Statistical Viz Large File

对 Excel 数据进行多维度统计分析与可视化。

- Repository: https://github.com/OpenSenseNova/SenseNova-Skills (6002 stars)
- Category: Documents
- License: MIT
- Last updated: 2026-10-29
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add OpenSenseNova/SenseNova-Skills --skill excel-statistical-viz-large-file -g -a claude-code -y`
Codex: `npx skills add OpenSenseNova/SenseNova-Skills --skill excel-statistical-viz-large-file -g -a codex -y`
Cursor: `npx skills add OpenSenseNova/SenseNova-Skills --skill excel-statistical-viz-large-file -g -a cursor -y`
Gemini CLI: `npx skills add OpenSenseNova/SenseNova-Skills --skill excel-statistical-viz-large-file -g -a gemini-cli -y`

## Description

对 Excel 数据进行多维度统计分析与可视化。

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# excel_statistical_visualization

> This sub-skill covers one capability of the Excel workflow. For reading/counting/Parquet optimization, see the parent workflow SKILL.md.

Step1 数据清洗与标准化。提取目标分析列，处理合并单元格（ffill），并利用正则表达式或类型转换清理数值字段，确保分析数据集的准确性。
```python
import re

# 假设 target_col_x 和 target_col_y 是分析目标
# 处理合并单元格导致的缺失值
df['group_col'] = df['group_col'].fillna(method='ffill')

def clean_numeric_string(value):
    if pd.isna(value): return None
    # 保留数字、小数点和负号，移除空格及非法字符
    cleaned = re.sub(r'[^\d\.\-]', '', str(value))
    try:
        return float(cleaned)
    except ValueError:
        return None

df['x_val'] = df['target_col_x'].apply(clean_numeric_string)
df['y_val'] = df['target_col_y'].apply(clean_numeric_string)

# 过滤无效数据
df_clean = df.dropna(subset=['x_val', 'y_val']).copy()
```

Step2 执行多维度统计分析。计算分类占比、均值、标准差，并构建交叉分析表（crosstab/pivot），为可视化提供数据支撑。
```python
# 分类统计与占比
stats_summary = df_clean.groupby('group_col')['y_val'].agg(['count', 'mean', 'std', 'min', 'max'])
stats_summary['percentage'] = (stats_summary['count'] / stats_summary['count'].sum()) * 100

# 添加总计行
total_row = pd.DataFrame(df_clean[['y_val']].agg(['count', 'mean']).T)
total_row.index = ['Total']

# 交叉分析示例
pivot_table = pd.pivot_table(df_clean, values='y_val', index='group_col', columns='category_col', aggfunc='count', fill_value=0)
```

Step3 生成高分辨率可视化图表。包含散点图、线性趋势线（R²、p值）、箱线图或柱状图组合，并配置中文字体与美化参数。
```python
import matplotlib.pyplot as plt
import matplotlib
from scipy import stats
import numpy as np

# 字体配置：优先使用 SimHei 或 DejaVu Sans 确保中文显示
matplotlib.rcParams['font.sans-serif'] = ['SimHei', 'WenQuanYi Zen Hei', 'DejaVu Sans']
matplotlib.rcParams['axes.unicode_minus'] = False

x = df_clean['x_val'].values
y = df_clean['y_val'].values

# 线性回归计算
slope, intercept, r_value, p_value, std_err = stats.linregress(x, y)
line = slope * x + intercept

plt.figure(figsize=(12, 8), dpi=300)

The rest: https://github.com/OpenSenseNova/SenseNova-Skills/blob/HEAD/skills/sn-da-excel-workflow/capability/excel-data-visualization/scatter-plot-visualization/SKILL.md
