Skip to content

Commit

Permalink
enh: Add .rows(named=False) support for pyarrow (#1155)
Browse files Browse the repository at this point in the history
  • Loading branch information
schloerke authored Oct 11, 2024
1 parent 6bbf46c commit 000c360
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
3 changes: 1 addition & 2 deletions narwhals/_arrow/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ def rows(
self, *, named: bool = False
) -> list[tuple[Any, ...]] | list[dict[str, Any]]:
if not named:
msg = "Unnamed rows are not yet supported on PyArrow tables"
raise NotImplementedError(msg)
return list(self.iter_rows(named=False)) # type: ignore[return-value]
return self._native_frame.to_pylist() # type: ignore[no-any-return]

def iter_rows(
Expand Down
8 changes: 0 additions & 8 deletions tests/frame/rows_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,6 @@ def test_rows(
expected: list[tuple[Any, ...]] | list[dict[str, Any]],
) -> None:
df = nw.from_native(df_raw, eager_only=True)
if isinstance(df_raw, pa.Table) and not named:
with pytest.raises(
NotImplementedError,
match="Unnamed rows are not yet supported on PyArrow tables",
):
df.rows(named=named)
return

result = df.rows(named=named)
assert result == expected

Expand Down

0 comments on commit 000c360

Please sign in to comment.