# IndexError：索引 5 超出轴 0 的范围（大小为 5）

- **ID:** `python/numpy-index-error-bounds`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

整数索引等于或超过数组长度；差一错误或轴错误。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   if 0 <= i < arr.shape[0]: val = arr[i]
   ```
2. **** (85% 成功率)
   ```
   arr.take([i], mode='clip') for clamped access
   ```

## 无效尝试

- **** — Silently drops data rows (70% 失败率)
- **** — Only fixes the last-index case (60% 失败率)
