We're curious to hear what you think. Let us know if we missed any of your favorite Polars operations, or if you have any feedback on how we organized it.
https://github.com/posit-dev/open-source-website/blob/main/c...
purchases |>
group_by(country) |>
filter(amount <= median(amount) * 10) |>
summarize(total = sum(amount - discount))I found `polars` to be a better experience than `pandas` even though I'd say it leaks some "Rustisms" in its Python APIs. But LLMs alleviate those pains and it's easy enough to review. I'd say it's even easier when there's less of a chance of implicit behavior.
Why do you say that? Base R is arguably nicer to work with data than pandas is for example. Happy to provide specific examples to prove my point if you want.
AI probably changes the equation to some extent, but I still believe I'd rather maintain a complicated data pipeline like that in Python rather than R.
Anyway, the general consensus at the time was that R was much nicer once you had your data, and if all you had to do was transform it. But that everything else was better in Python.
One of our group members did an experimental project, where you could open R inside of python and share memory. So you could theoretically do your API calls and screen scraping and whatnot in Python, then transform your data in R, then take the output and use it to do something else in Python. It was pretty cool, but I think it was just a POC and never really went anywhere.
I tried learning R after that, but didn't get very far with it.
I appreciate Polars offering some alternative APIs for poking around in data, though. I feel like at some point someone will land on a _very_ nice to use API
For example, last time I used it, you couldn't do NDJSON streaming scans from S3 (looks like fixed with PR #26563).
https://duckdb.org/docs/lts/sql/statements/pivot#limitations
vs
https://docs.pola.rs/api/python/stable/reference/dataframe/a...
using sql everywhere; never having to remember dataframe syntax: timeless
pl.col("...")
I think of `pl.col` as delayed evaluation: I want to do math on the vector of values of this column. But wait, let me just refer to the name of that column and build the expression that I want to compute. Then I hand this expression to Polars and it retrieves the actual values of the columns my expression refers to and executes the operations.
IMO, it would've been great to just do math on strings, like `"Amount" * "Price" - "Losses"`, but programming languages either don't allow math on strings or that math is actually string concatenation, which is not what we want. So we have to wrap the name of the column into some object. This is just an API thing.
As a side note, it's such a pity that there's basically no Polars for the Julia language! There is some wrapper package, but it seems old and unmaintained. I can't seem to properly learn DataFrames.jl for some reason, I always miss Polars when I use Julia.
df |> dplyr::mutate(profit = Amount * Price - Losses)
For Julia, take a look at TidierData.jl [2], which provides similar tidy syntax via macros. import polars as pl
from polars import col, litc.foo + c.bar
Would be a great addition to the cheatsheet.