7 ms·
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)
by aquafox 14d 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)
- bobson_dugnutt5 14d agoFair point, but you can do something like `df.select("x", y=pl.col.w/pl.col.z)`
- orlp 14d agofrom polars import col as C df.select(C.x, y = C.w / C.z)
- dkga 14d agoStill, it’s a very good approximation but still an approximation to the more ergonomic and expressive tidyverse syntax
- sanderjd 14d agoOne person's "ergonomic and expressive" is another person's "wait what in the world is actually going on here".
- __mharrison__ 14d agoThis is the way. Favor keyword arguments to alias.
- jcattle 14d agoR 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.
- vovavili 14d agoAltair 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.
- countrymile 14d agoPolars 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.
- sanderjd 14d agoTo 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.