Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong behavior description in polars.dataframe.group_by.GroupBy.__iter__ #17460

Closed
liufeimath opened this issue Jul 6, 2024 · 4 comments
Closed
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@liufeimath
Copy link
Contributor

Description

In this doc:
https://docs.pola.rs/api/python/stable/reference/dataframe/api/polars.dataframe.group_by.GroupBy.__iter__.html

It says

If a single string was passed to by, the keys are a single value instead of a tuple.

This is not true for 1.0.0, e.g.

df = pl.DataFrame({"foo": ["a", "a", "b"], "bar": [1, 2, 3]})
for name, data in df.group_by("foo"):  
    print(name)
    print(data)

prints

('a',)
shape: (2, 2)
┌─────┬─────┐
│ foo ┆ bar │
│ --- ┆ --- │
│ str ┆ i64 │
╞═════╪═════╡
│ a   ┆ 1   │
│ a   ┆ 2   │
└─────┴─────┘
('b',)
shape: (1, 2)
┌─────┬─────┐
│ foo ┆ bar │
│ --- ┆ --- │
│ str ┆ i64 │
╞═════╪═════╡
│ b   ┆ 3   │
└─────┴─────┘

Keys are still a tuple, not a single value.

Link

https://docs.pola.rs/api/python/stable/reference/dataframe/api/polars.dataframe.group_by.GroupBy.__iter__.html

@liufeimath liufeimath added the documentation Improvements or additions to documentation label Jul 6, 2024
@henryharbeck
Copy link
Contributor

This was fixed in #17383, so will be resolved on the next release.

@cmdlineluser
Copy link
Contributor

You can see the updated docs in the /dev/ section:

@liufeimath
Copy link
Contributor Author

Thanks for the info! All good now.

@nameexhaustion
Copy link
Collaborator

Fixed by #17383

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

No branches or pull requests

5 participants