# TypeError: 根据 'safe' 规则无法将数组数据从 dtype('O') 转换为 dtype('float64')

- **ID:** `python/numpy-dtype-object-no-cast`
- **领域:** python
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

object dtype 数组（通常是含混合类型或 None 的 pandas 列）被传给需要安全转换数值 dtype 的 NumPy/SciPy 函数。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   arr = pd.to_numeric(pd.Series(arr), errors='coerce').to_numpy(dtype=np.float64)
   ```
2. **** (85% 成功率)
   ```
   Clean first: arr = np.array([x for x in arr if x is not None], dtype=np.float64)
   ```

## 无效尝试

- **** — Raises ValueError on non-numeric strings (80% 失败率)
- **** — Keeps object dtype (85% 失败率)
