← Back to context

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)

    from polars import col as C

    df.select(C.x, y = C.w / C.z)

  • 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.

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.