logoalt Hacker News

aquafoxtoday at 9:15 AM5 repliesview on HN

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)


Replies

orlptoday at 9:55 AM

    from polars import col as C

    df.select(C.x, y = C.w / C.z)
show 2 replies
sanderjdtoday at 2:11 PM

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.

jcattletoday at 10:02 AM

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.

show 1 reply
bobson_dugnutt5today at 9:18 AM

Fair point, but you can do something like

`df.select("x", y=pl.col.w/pl.col.z)`

countrymiletoday at 12:00 PM

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.