Skip to content

docs: Add note on return type of columns property#3575

Open
FBruzzesi wants to merge 4 commits intomainfrom
docs/columns-return
Open

docs: Add note on return type of columns property#3575
FBruzzesi wants to merge 4 commits intomainfrom
docs/columns-return

Conversation

@FBruzzesi
Copy link
Copy Markdown
Member

Description

  1. Do you like the phrasing?
  2. Should we add the same note for the Schema spec? For the same reason we cannot guarantee it to be a Mapping from str to DType.

What type of PR is this? (check all applicable)

  • 💾 Refactor
  • ✨ Feature
  • 🐛 Bug Fix
  • 🔧 Optimization
  • 📝 Documentation
  • ✅ Test
  • 🐳 Other

Related issues

@FBruzzesi FBruzzesi added the documentation Improvements or additions to documentation label Apr 25, 2026
Comment thread narwhals/dataframe.py
Comment on lines +1357 to +1359
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]`.
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 :)

@EdAbati
Copy link
Copy Markdown
Collaborator

EdAbati commented Apr 26, 2026

Should we add the same note for the Schema spec? For the same reason we cannot guarantee it to be a Mapping from str to DType.

Do you mean in schema/collect_schema? I think think it'd be helpful 👍

We could also update the column_names.md to mention Dask too

@FBruzzesi
Copy link
Copy Markdown
Member Author

FBruzzesi commented Apr 26, 2026

Thanks for the feedback @EdAbati

Do you mean in schema/collect_schema? I think think it'd be helpful 👍

Both schema and collect_schema return a Schema object. I added similar notes in such class in beb053a

We could also update the column_names.md to mention Dask too

Updated the doc page in 934d15d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: narwhals.DataFrame.columns does not always return list of strings

2 participants