Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions narwhals/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,13 @@ def collect_schema(self) -> Schema:
def columns(self) -> list[str]:
"""Get column names.

Note:
The pandas-like and dask backends allow non-string column names
(e.g. integers or booleans). While discouraged, this is supported,
so the return type is not guaranteed to be `list[str]`.
Comment on lines +1357 to +1359
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the phrasing looks good!

I tried to find alternatives.

For the 2nd sentence we can use something like:
This is discouraged but supported, so the return type is not guaranteed to be list[str].

Or have it all one sentence:

Non-string column names (e.g. integers or booleans) are discouraged but supported by pandas-like and Dask backends, so the return type is not guaranteed to be list[str].

But again, I think your version looks good :)


See [concepts - column names](../concepts/column_names.md) for details.

Examples:
>>> import pyarrow as pa
>>> import narwhals as nw
Expand Down Expand Up @@ -2638,6 +2645,13 @@ def collect_schema(self) -> Schema:
def columns(self) -> list[str]:
r"""Get column names.

Note:
The pandas-like and dask backends allow non-string column names
(e.g. integers or booleans). While discouraged, this is supported,
so the return type is not guaranteed to be `list[str]`.

See [concepts - column names](../concepts/column_names.md) for details.

Examples:
>>> import duckdb
>>> import narwhals as nw
Expand Down
Loading