about pandas has centered on efficiency.
As its creator has acknowledged, pandas’ foundations weren’t constructed for in the present day’s knowledge workloads. Over time, pandas has made actual progress on this space, notably with the current pandas 3.0 launch. In the meantime, Polars and DuckDB have proven what may be achieved when trendy knowledge buildings are a part of the design from the start.
However efficiency is just one value in knowledge evaluation. For a lot of on a regular basis duties, back-end efficiency is a secondary concern. The dataset matches in reminiscence. The calculation finishes in a second. However the analyst has to take time to recollect an API, rearrange brackets, lookup an aggregation sample and verify whether or not a grouping key has quietly change into an index.
The CPU is idle. The human is just not.
The deeper downside with pandas—and, to completely different levels, with most dataframe APIs—is cognitive overhead.
The tax hidden in extraordinary code
Take into account a easy process: hold constructive gross sales, calculate a margin, summarise by area and kind the end result:
abstract = (
gross sales.loc[sales["revenue"] > 0]
.assign(margin=lambda df: df["revenue"] - df["cost"])
.groupby("area", as_index=False)
.agg(
total_revenue=("income", "sum"),
average_margin=("margin", "imply"),
)
.sort_values("total_revenue", ascending=False)
)
This isn’t unhealthy pandas. It’s not a intentionally terrible instance assembled to win a syntax comparability. An skilled pandas consumer can learn it with out issue.
However discover how a lot of the expression is about negotiating with the API slightly than detailing precise logic:
- A column is typically
gross sales["revenue"], generallydf["revenue"], and generally the string"income". - Making a column requires
assignand a lambda if we wish to protect the tactic chain. - A named aggregation is expressed as a tuple whose order is column first, operate second.
- Descending order is expressed by setting an
ascendingchoice toFalse. - The behaviour of the grouping key relies on
as_index, a parameter whose significance is just not apparent from the analytical process.
None of those particulars is individually troublesome. However every one consumes a small piece of human working reminiscence that would in any other case be used to consider knowledge.
pandas indexes are a very good instance of this stress. The acquainted look of .reset_index() after a group-by is just not only a few additional keystrokes; it’s an annoying distraction. And naturally, backward compatibility limits how radically a mature library can redesign its floor.
“AI can write it now” is simply half a solution
Who cares if pandas syntax is lower than excellent, you would possibly say. AI brokers can generate the pandas code for us now, so what does it matter? Sure, massive language fashions can save an excessive amount of time. However producing code is just one a part of analytical work.
Coding for knowledge evaluation is completely different from software program improvement. It typically begins with a query that modifications as quickly as the primary end result seems. You filter the info, discover one thing surprising, examine it, revise the grouping, uncover lacking values, make a chart after which realise that your authentic query was the mistaken one.
The workflow is just not:
> specification → code → completed product
It’s nearer to:
> query → transformation → end result → new query → new transformation
That loop is exploratory, inventive and interactive. On this setting, there’s worth in a human having the ability to manually remodel knowledge with minimal latency. I count on that many analysts are nonetheless discovering themselves typing small items of pandas code right into a pocket book, even when they’re now trusting AI to put in writing bigger capabilities or modules.
Readability issues
Secondly, whereas AI reduces the price of typing, it doesn’t take away the price of studying, checking and understanding.
A Python knowledge pipeline can be documentation. It tells a colleague—or your future self—what was filtered, which variables have been created, and the place the ultimate quantity got here from. The simpler that path is to observe, the better it’s to overview assumptions and catch errors.
Boilerplate weakens that documentation by decreasing the signal-to-noise ratio. The enterprise logic remains to be current, however it’s surrounded by dataframe names, column selectors, citation marks, lambdas, aliases and API-specific choices.
Let’s be sincere: studying different folks’s pandas code, particularly code that was constructed via an interactive session may be slightly painful. There isn’t any doubt that pandas code is just not probably the most concise or readable strategy to categorical the underlying logic of an information pipeline.
The rise of AI-generated code solely strengthens this argument. If extra code goes to be produced robotically, people want representations that make the generated logic straightforward to examine.
The enduring reputation of visible knowledge instruments
If you happen to’re nonetheless not satisfied that any of this issues, assume for a minute in regards to the reputation of visible knowledge instruments.
Excel stays embedded in analytical work throughout nearly each trade. Tableau, Energy BI, KNIME, Alteryx, Metabase, Orange, RapidMiner and lots of different merchandise supply completely different variations on the identical promise: contact the info extra straight, see suggestions rapidly and keep away from having to translate each thought right into a general-purpose programming API.
I exploit Excel lots. There are many events when dropping a small dataset right into a pivot desk is quicker than writing a pandas pipeline. Visible instruments may be extra intuitive and assist to cut back the latency from thought to end result.
In fact, code has a objective. A script gives an audit path from uncooked knowledge to end result. It may be reviewed, examined, versioned, rerun and shared. For this reason groups transfer crucial work out of spreadsheets within the first place. A number of trendy visible instruments now additionally generate pandas code for this very purpose, together with Information Wrangler and Mito.
But when “code-as-documentation” is type of the purpose, why are we utilizing boilerplate-laden pandas code as our language of alternative? Why not one thing that’s simpler for people to learn?
Why does each dataframe want a brand new dialect?
The cognitive value is just not confined to pandas.
Transfer to Polars and the underlying analytical concepts stay the identical: choose, filter, derive, group, mixture, be part of and kind. However the syntax modifications. Transfer from Python to R, Julia or MATLAB and it modifications once more.
There is perhaps good causes for these variations, however from an analyst’s perspective, it’s unusual that the identical logical operation should be relearned as a brand new dialect in every surroundings. As an information analyst, statistical work would possibly take me to R. Simulation or optimisation might take me to Julia or MATLAB. A bigger-than-memory transformation might take me to DuckDB. Why ought to this additionally require altering the grammar during which I categorical group by area, then sum income?
DSLs to the rescue?
Most dataframe awkwardness comes from embedding a data-transformation grammar inside a general-purpose programming language.
Python wants to tell apart variables, attributes, strings, record indexing, operate calls and task. A dataframe library has to assemble its language from those self same items. That’s the reason column names change into strings, why the lively dataframe is repeatedly referenced and why a easy expression can accumulate punctuation:
gross sales.loc[sales["revenue"] > 0, "margin"] = (
gross sales["revenue"] - gross sales["cost"]
)
A site-specific language (DSL) could make completely different decisions as a result of it has a narrower job. SQL is the strongest proof this method works. It gave knowledge work a shared vocabulary that survived modifications in {hardware}, distributors and host programming languages. Its sturdiness is just not an accident.
However SQL will not be the ultimate reply for each analytical workflow. SQL was designed for querying relational databases, not the complete interactive loop of loading native knowledge, reworking it, plotting it, calling a mannequin and saving a set of outputs. Its conventional clause order doesn’t learn as a top-to-bottom pipeline, and sophisticated work typically expands into nested queries or chains of frequent desk expressions.
Tasks similar to PRQL and pipe syntax in SQL enhance SQL’s top-to-bottom readability significantly, whereas DuckDB has made SQL really feel at house in native Python workflows.
DuckDB’s reputation is itself an attention-grabbing case examine. Its current consumer survey confirmed that many customers don’t even have larger-than-memory datasets, and past efficiency they worth DuckDB for its ease of use and SQL help.
However DuckDB, PRQL and piped-SQL are in the end nonetheless extensions of standard SQL. DuckDB can remodel tables effective, however plotting and different frequent analytical operations nonetheless need to be performed in Python, which suggests switching again to a dataframe API. DuckDB might execute the transformation quick sufficient, however from an analyst’s perspective, switching forwards and backwards goes to interrupt stream.
Pivotal as an experiment
These issues are what led me to construct Pivotal, an open-source DSL for knowledge evaluation in Python.
Pivotal is just not a alternative for the Python ecosystem. It’s a compact strategy to categorical frequent analytical operations, which might then compile to Python code utilizing pandas, Polars or DuckDB. The purpose is to separate the logic the analyst writes from the engine that executes it.
The sooner pandas instance turns into:
with gross sales as abstract
filter income > 0
margin = income - value
group by area
agg sum income as total_revenue, imply margin as average_margin
type total_revenue desc
The distinction isn’t just character depend. Every line corresponds to an analytical concept. The lively desk is said as soon as. Columns are columns slightly than strings. The grouping and its aggregations kind a visual block. Studying from prime to backside follows the order during which the analyst is pondering.
As a result of Pivotal compiles to extraordinary Python, its outcomes stay obtainable to the remainder of the Python ecosystem. Pivotal additionally contains instructions for plots, tables and saving outputs, whereas common Python stays obtainable as an escape hatch when the DSL is just not the precise device.
In fact, Pivotal may not be the one syntax to rule all of them. It’s a younger venture with its personal trade-offs. Customers need to study it. Tooling is proscribed (VS Code and JupyterLab solely) and group help is non-existent. pandas has a variety of inertia and for groups with established codebases (together with my very own) a brand new language is a troublesome promote.
However Pivotal is an experiment in a design area that has been underexplored. We benchmark execution time fastidiously. We must also care about comprehension time, error visibility and the variety of ideas an analyst should hold of their head to specific a easy transformation.
Past programming languages
It’s an attention-grabbing time to be alive. Once I began my profession within the early 2000s, we used Excel and Visible Primary for knowledge wrangling, and paid software program like SAS and Stata for evaluation. Python was nonetheless area of interest (no less than in my circles), and pandas and scikit-learn have been years away. Since then, the Python knowledge ecosystem has change into entrenched throughout academia, trade and authorities IT environments.
Whereas lots has modified, this appears tame compared with the disruption AI is poised to unleash.
The rise of AI coding brokers over the previous 12 months has lots of people questioning about the way forward for programming. Will we see new languages and DSLs evolve for interacting with brokers? Or ought to brokers produce extra summary or visible representations of logic as a substitute of code, like an information pipeline diagram (e.g., an Airflow- or KNIME-style DAG).
What in regards to the world of visible knowledge instruments? At a time when computer systems perceive human speech, point-and-click interfaces are beginning to really feel a bit quaint. On the similar time, we’d see a convergence of those merchandise, with instruments that blend pure language, visible interplay and code technology seamlessly.
I don’t know what the profitable interface will appear like, however I do know that we are able to do higher. As a result of df.groupby("12 months").reset_index() can’t be the height of human achievement.















