-
-
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
depr(python,rust!): Rename DataFrame.melt
to unpivot
and make parameters consistent with pivot
#17095
Conversation
039b57a
to
a517e9a
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17095 +/- ##
==========================================
+ Coverage 80.86% 80.87% +0.01%
==========================================
Files 1456 1456
Lines 191141 191137 -4
Branches 2728 2728
==========================================
+ Hits 154562 154585 +23
+ Misses 36073 36046 -27
Partials 506 506 ☔ View full report in Codecov by Sentry. |
id_vars -> index, value_vars -> on
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.
Whew, quite a lot of churn to get through it looks like!
I know this is still in draft, but I wanted to mention: we should keep melt
but deprecate it, so we can remove it with 2.0.0.
ah sorry, when you said to get rid of |
Love it! 😄 Question: Asking because the idea was to align the parameters of |
Alright! Ready to undraft? |
almost, just finishing up |
column
in DataFrame.pivot
to on
Sure, done I do like how it becomes symmetrical, which probably makes things easier for new users, so thanks @JulianCologne for the suggestion. There is some code churn for existing users, but it's a fairly easy find-and-replace |
Thanks Marco, looks good! Just one question about the design: What do you think about making |
column
in DataFrame.pivot
to on
DataFrame.melt
to unpivot
and make parameters consistent with pivot
DataFrame.melt
to unpivot
and make parameters consistent with pivot
DataFrame.melt
to unpivot
and make parameters consistent with pivot
For pivot I don't think that can be done in a non-breaking way, at least not without first making the arguments keyword-only. And so if the order in |
For pivot, non-keyword args were already deprecated, related to this issue: #12087 I had just removed this deprecation for 1.0, so we can change their order without breaking anything right now. So we are really free in determining the most intuitive API here. Would it be better with |
ah, cool! in that case, agree, |
not sure I understand sorry - am I OK to make the arguments keyword-only as part of this PR? It still needs enforcing, right? |
You don't need to make them keyword-only, you can just move the parameters as you see fit. If you look at the latest release (0.20.31), you can see that non-keyword arguments were already deprecated: So at this point, everyone has their args as keyword arguments (theoretically speaking). So we are free to move around the parameters as we see fit for the 1.0 release. |
I feel a bit uneasy about this one, I think it's going to silently break people's code. Though I think the current change in argument order is already going to break it anyway, so let's think if there's a better way I think the following would feel natural, and would loudly break for anyone who didn't pay attention to their warnings (based on some clients I've worked with, I'd estimate that that's the majority 😩 ): def pivot(self, on, *, values=None, index=None): ... Then the call becomes:
if you don't specify either of If we could do that, I'd feel a lot easier about changing the order. I also think it would lead to more readable code if |
Sure that sounds good. Let's do |
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.
Looks great, thanks Marco!
Closes #11974
The diff isn't super-clear in one bit, but
py-polars/tests/unit/operations/test_melt.py
is just renamed topy-polars/tests/unit/operations/test_unpivot.py
but with an extra couple ofwith pytest.deprecated_call