Skip to content
FunCoding

excel_column_stats

统计 Excel 每一列的填充率、类型、唯一值数量和数值分布,用于数据质量初筛。当用户提到 Excel 列统计、数据质量、缺失率、列画像时使用。

Star
1,372
License
Apache-2.0
Last commit
Oct 29, 2026

skills/excel/excel_column_stats/SKILL.md

View on GitHub

excel_column_stats Skill

给 Excel 每一列做一次「体检」:填充率、类型、唯一值、数值分布

功能描述

逐列统计非空数量、空值占比、去重后的取值个数,并推断列类型 (number / text / date / mixed / empty)。数值列额外给出最小值、最大值、 均值、中位数和样本标准差;文本列给出出现次数最多的前 N 个值。

适合在正式处理数据之前先看一眼:哪列缺失严重、哪列数字里混了文本、数值量级是否合理。

所属分类

skills/excel/excel_column_stats/

调用方式

from skills.excel import excel_column_stats

excel_column_stats(excel_path='销售明细.xlsx', top_n=3)

参数说明

参数类型必填默认值说明
excel_pathstr是-需要统计的 Excel 路径
sheet_namestr否None工作表名,默认取第一个
top_nint否5文本列返回前 N 个高频值,0 表示不返回

返回值

dict,包含 sheet、row_count、column_count、fill_rate、columns。 columns 是列表,每项含 name、index、filled、empty、empty_ratio、 unique、type,并按类型附带 numeric、date_range 或 top。

使用示例

from skills.excel import excel_column_stats

stats = excel_column_stats('销售明细.xlsx')
print('整体填充率:{:.1%}'.format(stats['fill_rate']))
for column in stats['columns']:
    print('{}({}):空值 {} 个'.format(column['name'], column['type'], column['empty']))
    if column['type'] == 'number':
        print('  均值 {mean},中位数 {median}'.format(**column['numeric']))

原始函数

contributors/my12yyds/excel_column_stats.py

Similar Skills

Featured

pptx

Create and edit slide decks, generate slides from templates, and extract text.

ANanthropics/skills203k2,822 new stars in the last 7 days

Featured

docx

Create and edit Word docs with TOC, page numbers, headers and more.

ANanthropics/skills203k2,822 new stars in the last 7 days

Featured

pdf

Read and edit PDFs: extract text and tables, merge, split, rotate, and fill forms.

ANanthropics/skills203k2,822 new stars in the last 7 days

Featured

doc-coauthoring

Co-write specs, proposals and decision docs through a structured, iterative workflow.

ANanthropics/skills203k2,822 new stars in the last 7 days

Featured

xlsx

Read and edit spreadsheets: add columns, compute formulas, format, and clean messy data.

ANanthropics/skills203k2,822 new stars in the last 7 days

Featured

canvas-design

Create posters and visual art as PNG or PDF, guided by a design philosophy.

ANanthropics/skills203k2,822 new stars in the last 7 days