-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
fix: Allow index=None
in pivot()
#15855
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #15855 +/- ##
===========================================
+ Coverage 39.14% 80.38% +41.24%
===========================================
Files 1364 1263 -101
Lines 167705 165371 -2334
Branches 3031 0 -3031
===========================================
+ Hits 65646 132938 +67292
+ Misses 101592 32433 -69159
+ Partials 467 0 -467
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@MarcoGorelli any opinion on this? I always have to think hard on pivots. ^^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for working on this!
the expected output looks correct to me - it would be like doing
df.with_columns(_tmp=pl.lit("a")).pivot(
index="_tmp", columns="foo", values=["N", "M"], aggregate_function=None
).drop("_tmp")
right?
I'll take a look at the implementation next week
py-polars/polars/dataframe/frame.py
Outdated
Set the index to None to output a single row. | ||
>>> df = pl.DataFrame( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure this renders properly? i think you need an extra blank line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes I didn't see that. Fixed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now I'm going to block this (sorry Oliver!) as I'm not really sure about it, see #11592 (comment)
thanks for your PR! I think what you're suggesting can already be achieved more clearly with groupby-agg-transpose (#11592 (comment)), and closing then, but thanks for your contribution, and sorry to do this |
Closes #11592
I ran into this 'backlog' issue and decided to implement a fix.
I don't usually write rust code so apologies if something is a little shaky.