python
data_error
ai_generated
true
ValueError:没有要连接的对象
ValueError: No objects to concatenate
ID: python/pandas-concat-empty
80%修复率
90%置信度
0证据数
2024-08-12首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
pd.concat 接收到空的 DataFrame 列表。
English
pd.concat called with an empty list of DataFrames.
解决方案
-
95% 成功率
if dfs: result = pd.concat(dfs, ignore_index=True) else: result = pd.DataFrame()
-
90% 成功率
pd.concat(dfs or [pd.DataFrame()], ignore_index=True)
无效尝试
常见但无效的做法:
-
75% 失败
Propagates None into downstream code
-
70% 失败
Creates unexpected row/column structure