-
-
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
chore(python): Deprecate positional join
args
#6826
Conversation
34e052a
to
e315b26
Compare
e315b26
to
c32c74c
Compare
This is great. These things really enhance readability and maintainability. 👍 |
This one just really bit me, and the API reference doesn't have a decent example. In 0.16.4 I had something like this:
That worked great for me. I understand the reason for the change completely, but something like
gives me an error for multiple values for argument 'how'. Like I said, is there an example for how this decorator works? I'm not really understanding how to work with the change. |
I can't reproduce this, could you show a reproducible example please? In [31]: df.join(df2, on=None, how='inner', left_on=['a'], right_on=['b'])
Out[31]:
shape: (3, 3)
┌─────┬─────┬─────────┐
│ a ┆ b ┆ a_right │
│ --- ┆ --- ┆ --- │
│ i64 ┆ i64 ┆ i64 │
╞═════╪═════╪═════════╡
│ 1 ┆ 1 ┆ 1 │
│ 1 ┆ 2 ┆ 1 │
│ 2 ┆ 3 ┆ 1 │
└─────┴─────┴─────────┘ |
OK, sorry about that. That code does work. I had multiple joins in my code and the error was in the next join. That "*" really threw me off. My apologies. |
This is a PoC of sorts to deprecate positional arguments.
As an example, the function signature for
join
is as follows:I think the function signature below would make more sense, putting the most-used args first, and make others keyword-only:
This is obviously a breaking change, but worse, this may silently break for people who have specified
left_on
andright_on
positionally.I came up with a way to detect such cases and throw aDeprecationWarning
I stole the decorator from Pandas (as suggested by @MarcoGorelli) and adapted it to our needs.
If you agree with this method of deprecating non-keyword arguments, I will go ahead and apply this to a bunch of other functions.
Changes:
join
method.