Skip to content
FunCoding

excel_dedupe

按指定列或整行给 Excel 去重,返回重复行与保留行的对应关系,可导出干净数据。当用户提到 Excel 去重、删除重复项、重复数据、查重时使用。

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

skills/excel/excel_dedupe/SKILL.md

View on GitHub

excel_dedupe Skill

按指定列给 Excel 去重,并说明哪一行和哪一行重复

功能描述

按一个列、多个列或整行判断重复,保留第一次(或最后一次)出现的记录, 同时返回重复明细:重复的是第几行、和保留的第几行重复、去重键是什么。 只给「去重后剩多少行」往往不够排查问题,所以重复明细是重点。

所属分类

skills/excel/excel_dedupe/

调用方式

from skills.excel import excel_dedupe

excel_dedupe(
    excel_path='客户名单.xlsx',
    key_columns=['手机号'],
    output_path='去重后.xlsx',
)

参数说明

参数类型必填默认值说明
excel_pathstr是-需要去重的 Excel 路径
key_columnsstr | list否None去重列,单个列名或列名列表;默认整行
sheet_namestr否None工作表名,默认取第一个
keepstr否'first'重复时保留 'first' 或 'last'
case_sensitivebool否True文本是否区分大小写
output_pathstr否None去重结果输出路径

返回值

dict,包含 sheet、key_columns、total、unique、duplicate_count、 duplicates、output_path。duplicates 每项含 row、kept_row、key。

使用示例

from skills.excel import excel_dedupe

result = excel_dedupe('客户名单.xlsx', key_columns='手机号')
print('共 {} 行,去重后 {} 行'.format(result['total'], result['unique']))
for item in result['duplicates']:
    print('第 {} 行与第 {} 行重复:{}'.format(item['row'], item['kept_row'], item['key']))

原始函数

contributors/my12yyds/excel_dedupe.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