Skip to content

Commit 3783fd2

Browse files
columns property added in (#670)
Co-authored-by: Marco Edward Gorelli <marcogorelli@protonmail.com>
1 parent 55c9a86 commit 3783fd2

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

narwhals/_dask/dataframe.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ def collect(self) -> Any:
5555
backend_version=parse_version(get_pandas().__version__),
5656
)
5757

58+
@property
59+
def columns(self) -> list[str]:
60+
return self._native_dataframe.columns.tolist() # type: ignore[no-any-return]
61+
5862
def lazy(self) -> Self:
5963
return self
6064

tests/dask_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,16 @@ def test_str_to_lowercase(
271271
compare_dicts(result_frame, expected)
272272

273273

274+
def test_columns() -> None:
275+
import dask.dataframe as dd
276+
277+
dfdd = dd.from_pandas(pd.DataFrame({"a": [1, 2, 3], "b": ["cat", "bat", "mat"]}))
278+
df = nw.from_native(dfdd)
279+
280+
result = df.columns
281+
assert result == ["a", "b"]
282+
283+
274284
def test_select() -> None:
275285
import dask.dataframe as dd
276286

0 commit comments

Comments
 (0)