Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Update ergonomics across the user-guide #365

Merged
merged 3 commits into from
Jul 6, 2023
Merged

Update ergonomics across the user-guide #365

merged 3 commits into from
Jul 6, 2023

Conversation

avimallu
Copy link
Contributor

@avimallu avimallu commented Jul 4, 2023

As discussed on Discord.

After pola-rs/polars#6451, parts of the user-guide were not updated with the newer ergonomics. This does not lead to the examples not working, but leads to Polars code looking rather cluttered. In addition, it can lead to user confusion since most Polars code now doesn't have these restrictions. For example:

out = df.select(
    [
        pl.struct(["keys", "values"])
        .apply(lambda x: len(x["keys"]) + x["values"])
        .alias("solution_apply"),
        (pl.col("keys").str.lengths() + pl.col("values")).alias("solution_expr"),
    ]
)

can and should now be written as:

out = df.select(
    pl.struct(["keys", "values"])
    .apply(lambda x: len(x["keys"]) + x["values"])
    .alias("solution_apply"),
    (pl.col("keys").str.lengths() + pl.col("values")).alias("solution_expr")
)

This PR updates such cases that are scattered across the user guide's Python code files. The migrating section had some of this content within the markdown itself, so I updated the two files there as well.

@avimallu
Copy link
Contributor Author

avimallu commented Jul 6, 2023

Conflicts resolved - simply had the column selection code from the earlier functions page.

@ritchie46 ritchie46 merged commit d5decdd into pola-rs:master Jul 6, 2023
5 checks passed
@avimallu avimallu deleted the context_ergonomics branch July 6, 2023 19:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants