from_df fails with std::bad_cast on a reversed DataFrame mixing string and float columns
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 66/100
研究方向
Start by reading the Python DataFrame registration path used by DuckDBPyConnection.from_df and the replacement scan, then look for tests covering reversed pandas views and mixed column types. Reproduce with the issue's two-column example and compare it with the copied frame. Done when both entry points handle the negative-stride view and a regression test verifies the result.
由索引模型根據 Issue 內容生成。
描述
What happens?
DuckDBPyConnection.from_df (and a replacement scan of the same frame) fails on a DataFrame that is a negative-stride view, such as df.iloc[::-1], when it mixes a string (object or str) column with a float column. On 2.0.0 the error is std::bad_cast; on 1.3.2 and 1.5.6 it is Unable to cast Python instance of type <class 'int'> to C++ type '?'.
A copy of the same view (df.iloc[::-1].copy()) works, and so does a reversed frame with a single column, or with only string columns.
To Reproduce
import duckdb
import pandas as pd
df = pd.DataFrame({"a": ["x", "y"], "b": [1.0, 2.0]})
duckdb.connect().from_df(df.iloc[::-1]).fetchall()
# duckdb.Error: std::bad_cast
duckdb.connect().from_df(df.iloc[::-1].copy()).fetchall()
# [('y', 2.0), ('x', 1.0)]
| DuckDB | pandas | result |
|---|---|---|
| 2.0.0 | 3.1.1 | std::bad_cast |
| 2.0.0 | 2.3.3 | std::bad_cast |
| 1.5.6 | 3.1.1 | Unable to cast Python instance of type <class 'int'> to C++ type '?' |
| 1.3.2 | 2.3.3 | Unable to cast Python instance of type <class 'int'> to C++ type '?' |
OS:
Linux x86_64 (Pop!_OS, kernel 7.2)
DuckDB Package Version:
2.0.0
Python Version:
3.13.2
Full Name:
Jonas Hörsch
Affiliation:
Open Energy Transition
What is the latest build you tested with?
2.0.0 from PyPI (latest release)
Did you include all relevant data sets for reproducing the issue?
Not applicable: the reproduction creates its own data.
Did you include all code required to reproduce the issue?
- Yes, I have
Did you include all relevant configuration to reproduce the issue?
- Yes, I have
- 主要語言
- Python
- 星號
- 203
- 分支
- 124
- 平均合併
- 14 小時 14 分鐘
- 30 天內合併 PR
- 70
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
duckdb/duckdb-python 的其他 Issue
-
query_graph fails with duckdb 2可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉needs triage
難度 2/5 1-3 小時 新手友好度 77/100
duckdb/duckdb-python#752 ·
維護者通常 1 天內回覆
-
`read_json` accepts a list of paths at runtime but the type stub only allows a single path.可能已有人在做 @aleks-drozy 於 101 天前認領。 未關閉needs triage
難度 2/5 1-3 小時 新手友好度 78/100
duckdb/duckdb-python#576 · 1 則留言 ·
維護者通常 1 天內回覆
-
Missing ROW_GROUPS_PER_FILE argument in write_parquet function可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉needs triage
難度 2/5 1-3 小時 新手友好度 68/100
duckdb/duckdb-python#386 ·
維護者通常 1 天內回覆
-
DuckDBPyRelation.create_view cannot create a view in another schema or database可能已有人在做 @el-marvin 今天認領。 未關閉
難度 3/5 1-2 天 新手友好度 54/100
duckdb/duckdb-python#753 ·
維護者通常 1 天內回覆
-
needs triage
難度 3/5 1-2 天 新手友好度 68/100
duckdb/duckdb-python#733 · 2 則留言 ·
維護者通常 1 天內回覆
查看 duckdb/duckdb-python 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 68/100
django-cms/djangocms-frontend#413 ·
-
難度 2/5 1-3 小時 新手友好度 82/100
NanmiCoder/MediaCrawler#1004 ·
-
難度 2/5 1-3 小時 新手友好度 72/100
facebookresearch/xformers#1417 ·
-
question
難度 1/5 1 小時以內 新手友好度 68/100
vllm-project/vime#524 ·
維護者通常 7 天內回覆
-
難度 2/5 1-3 小時 新手友好度 73/100
FinanceFlash/unvibecode#675 ·
維護者通常 1 天內回覆