Both have terrible syntax that make SQL look like the most readable thing ever.
Could not agree less. Ive always found SQL an unreadable mess but tools like polars and dplyr are such elegant ways to manipulate data.
Pandas is a mess though.
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)
What is it about polars syntax you don't like? The fact that is very verbose? At first I wasn't a fan, but over time I've grown to really like it. That never happened to me with pandas, always felt the syntax was messy
You can query polars data frames with SQL: https://docs.pola.rs/api/python/stable/reference/expressions...
Unfortunately, polars does not support parameterized queries, so the risk of SQL injection is extremely high.
I tend to agree. SQL may have been harder to write in the past (worse autocomplete than pandas/polars), but now that AI is writing the code, SQL is usually much easier to read. So DuckDB is another interesting alternative to pandas.
I agree sql is more elegant. The problems arise when you have to add logic on top of sql. Often I end up constructing queries via string manipulation and that is not very ergonomic. Polars api is more verbose and complex than sql but at least it's not meta-programming.
The duckdb python api is okay, but it is a bit limited, no ctes, no as of join, and it can be slow at bind/interpretation time when you do stuff like unioning multiple relations in a loop (I think that becomes O(N^2), but I might be wrong). Most issues can be worked around, but Polars is designed from the ground up to be used from python.