Skip to content

Commit

Permalink
specialised pyarrow path
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Feb 21, 2025
1 parent 89fa0cd commit c0e59dd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 4 additions & 1 deletion py-polars/polars/convert/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ def from_dataframe(
)
else:
allow_copy = True
if is_pycapsule(df):
if is_pycapsule(df) and not _check_for_pyarrow(df):
try:
return pycapsule_to_frame(df, rechunk=rechunk)
except Exception as exc:
Expand All @@ -911,6 +911,9 @@ def from_dataframe(
"Falling back to Dataframe Interchange Protocol, which is known to be less robust.",
UserWarning,
)
elif isinstance(df, (pa.Table, pa.RecordBatch)):
# Workaround for https://github.com/pola-rs/polars/issues/21384.
return wrap_df(arrow_to_pydf(data=df, rechunk=rechunk))
from polars.interchange.from_dataframe import from_dataframe

result = from_dataframe(df, allow_copy=allow_copy) # type: ignore[arg-type]
Expand Down
5 changes: 1 addition & 4 deletions py-polars/tests/unit/interchange/test_from_dataframe.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import os
from datetime import date, datetime, time, timedelta
from typing import Any

Expand Down Expand Up @@ -158,9 +157,7 @@ def test_from_dataframe_chunked() -> None:
assert result.n_chunks() == 2


def test_from_dataframe_chunked_string(request: pytest.FixtureRequest) -> None:
if os.environ.get("POLARS_AUTO_NEW_STREAMING") == "1":
request.applymarker(pytest.mark.xfail)
def test_from_dataframe_chunked_string() -> None:
df = pl.Series("a", ["a", None, "bc", "d", None, "efg"]).to_frame()
df_chunked = pl.concat([df[:1], df[1:3], df[3:]], rechunk=False)

Expand Down

0 comments on commit c0e59dd

Please sign in to comment.