Skip to content

Commit 86e33df

Browse files
committed
catch arrowinvalid and keep raising runtimeerror
1 parent e7eafc7 commit 86e33df

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

pandas/core/interchange/from_dataframe.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ def from_dataframe(df, allow_copy: bool = True) -> pd.DataFrame:
9999
# fallback to _from_dataframe
100100
pass
101101
else:
102-
return pa.table(df).to_pandas(zero_copy_only=not allow_copy)
102+
try:
103+
return pa.table(df).to_pandas(zero_copy_only=not allow_copy)
104+
except pa.ArrowInvalid as e:
105+
raise RuntimeError(e) from e
103106

104107
if not hasattr(df, "__dataframe__"):
105108
raise ValueError("`df` does not support __dataframe__")

pandas/tests/interchange/test_impl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def test_multi_chunk_pyarrow() -> None:
287287
names = ["n_legs"]
288288
table = pa.table([n_legs], names=names)
289289
with pytest.raises(
290-
pa.ArrowInvalid,
290+
RuntimeError,
291291
match="Cannot do zero copy conversion into multi-column DataFrame block",
292292
):
293293
pd.api.interchange.from_dataframe(table, allow_copy=False)

0 commit comments

Comments
 (0)