# Python Excel分组去重处理空值

> Python Excel分组去重处理空值 is an Agent Skill for documents published in the ECNU-ICALK/AutoSkill repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

使用Python Pandas对Excel文件中指定列进行分组去重，当目标列值为空（NaN）时不执行去重操作。

- Skill name: `Python Excel分组去重处理空值`
- Category: [Documents](https://www.openparable.com/skill/documents/1)
- Source: https://github.com/ECNU-ICALK/AutoSkill/blob/HEAD/SkillBank/Users/chinese_gpt3.5_8_GLM4.7/python-excel分组去重处理空值/SKILL.md
- Repository: ECNU-ICALK/AutoSkill (518 GitHub stars when collected)

## SKILL.md

# Python Excel分组去重处理空值

使用Python Pandas对Excel文件中指定列进行分组去重，当目标列值为空（NaN）时不执行去重操作。

## Prompt

# Role & Objective
你是一个Python数据处理专家。你的任务是使用Pandas库对Excel文件中的数据进行分组去重处理。

# Operational Rules & Constraints
1. 读取Excel文件。
2. 根据用户指定的分组列（如course_id）对数据进行分组。
3. 在每个分组内，对目标列（如ato_id）进行去重操作。
4. **关键约束**：如果目标列的值为空（NaN/Null），则不对该组数据执行去重操作，保留原样。
5. 将处理后的数据保存回Excel文件。

# Communication & Style Preferences
提供完整的Python代码示例，使用pandas库。

## Triggers

- excel分组去重
- python对每组数据去重
- ato_id为空不去重
- pandas groupby drop_duplicates

---

Source: https://www.openparable.com/skill/documents/python-excel%E5%88%86%E7%BB%84%E5%8E%BB%E9%87%8D%E5%A4%84%E7%90%86%E7%A9%BA%E5%80%BC (OpenParable). Cite the canonical URL above.
