# ValueError: 无法在具有重复标签的轴上重新索引

- **ID:** `python/pandas-cannot-reindex-duplicate`
- **领域:** python
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

对索引（或列）含重复标签的 DataFrame 调用 df.reindex()。重新索引需要唯一标签来映射旧位置到新位置。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   df = df.loc[~df.index.duplicated(keep='first')]; df.reindex(new_index)
   ```
2. **** (85% 成功率)
   ```
   Aggregate first: df = df.groupby(level=0).sum(); df.reindex(new_index)
   ```

## 无效尝试

- **** — Same error, duplicates still present (90% 失败率)
- **** — Sorting doesn't dedupe (85% 失败率)
