Skip to content

Commit

Permalink
columns property added in (#670)
Browse files Browse the repository at this point in the history
Co-authored-by: Marco Edward Gorelli <marcogorelli@protonmail.com>
  • Loading branch information
benrutter and MarcoGorelli authored Jul 29, 2024
1 parent 55c9a86 commit 3783fd2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions narwhals/_dask/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def collect(self) -> Any:
backend_version=parse_version(get_pandas().__version__),
)

@property
def columns(self) -> list[str]:
return self._native_dataframe.columns.tolist() # type: ignore[no-any-return]

def lazy(self) -> Self:
return self

Expand Down
10 changes: 10 additions & 0 deletions tests/dask_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,16 @@ def test_str_to_lowercase(
compare_dicts(result_frame, expected)


def test_columns() -> None:
import dask.dataframe as dd

dfdd = dd.from_pandas(pd.DataFrame({"a": [1, 2, 3], "b": ["cat", "bat", "mat"]}))
df = nw.from_native(dfdd)

result = df.columns
assert result == ["a", "b"]


def test_select() -> None:
import dask.dataframe as dd

Expand Down

0 comments on commit 3783fd2

Please sign in to comment.