-
Notifications
You must be signed in to change notification settings - Fork 83
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
feat: add with_columns
#909
Conversation
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.
This is a great addition!
python/datafusion/dataframe.py
Outdated
Example usage: | ||
|
||
The following will add 4 columns labeled a, b, c, and d. | ||
|
||
df = df.with_columns( | ||
lit(0).alias('a'), | ||
[lit(1).alias('b'), lit(2).alias('c')], | ||
d=lit(3) | ||
) |
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.
Do you know if this renders right in the online doc? If not, I can pull your branch and test it out
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.
@timsaucer I am not sure, is it possible to locally build the docs?
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.
Yes, there is a build script in the docs
folder and then you can open the generated html files locally.
Which issue does this PR close?
with_column
withwith_columns
#838Rationale for this change
Gives more flexibility to the user.
What changes are included in this PR?
Adds a
with_columns
which is a wrapper around with_column in Rust, the schema_name of the expr is used as the name. However I think we could improve over this in a follow up, since we should keep the original name unless somewhere down the expr path alias was called.See this example of Polars VS Datafusion now:
original df
Polars
Datafusion
Are there any user-facing changes?
Adds new
with_columns
method on DataFrame.