Comment by aquafox
3 days ago
Coming from an R/dplyr background, I agree. Compare
df.select(
pl.col("x"),
(pl.col("w")/pl.col("z")).alias("y")
)
with
df |> select(x, y = w/z)
3 days ago
Coming from an R/dplyr background, I agree. Compare
df.select(
pl.col("x"),
(pl.col("w")/pl.col("z")).alias("y")
)
with
df |> select(x, y = w/z)
This is the way. Favor keyword arguments to alias.
Still, it’s a very good approximation but still an approximation to the more ergonomic and expressive tidyverse syntax
One person's "ergonomic and expressive" is another person's "wait what in the world is actually going on here".
R really is/was the superior traditional data science language. Python ecosystem is slowly catching up though.
ggplot vs matplotlib
dplyr vs pandas
And I loved that everything in RStudio was so easily inspectable. Have a huge dataframe? Just look at it right in your IDE.
Altair and Positron should be just as good for your Polars @ Python needs. With software like Marimo notebooks and VegaFusion, Polars/Python experience starts beating R by quite a substantial margin.
Fair point, but you can do something like
`df.select("x", y=pl.col.w/pl.col.z)`
To me, I immediately wonder whether w, x, y, and z here are variables or column names. It would indeed be nice if python could more tersely represent the distinction between a name and a literal string (or worse, as in your R example, a variable reference), but alas. But I think trading some verbosity for explicitness about this distinction is a pretty good trade, and very in keeping with python style.
Polars is a world away from pandas, but I feel that dplyr still offers the most simple and understandable introduction to data analysis for the beginner. The above is a good example of this.