Python Pandas Numba

Compiled-code speed for the world's most popular DataFrame library — without leaving pandas.

numba @njit can speed up the calculation by hundreds of times — see example →

pandas is by far the most popular way to work with tables of data in Python. It is quick when an operation runs over a whole column at once, but the moment you need a real loop, a row‑by‑row rule, or anything its built‑in operations do not cover, you drop back to plain Python — and that part is slow. Those un‑optimized Python stretches are the weak point of an otherwise excellent library.

numba is a well‑established tool that compiles Python functions down to native machine code (via LLVM, the compiler technology behind C), routinely turning that slow loop into something hundreds of times faster. The catch has always been getting your pandas data across the boundary into compiled code. Pandas Numba removes exactly that hard part: a simple but remarkably efficient mechanism that hands your DataFrame columns straight into compiled @njit code. You concentrate on the code you want to write, not on the interface between the two worlds.

Under the hood it is a tiny numba container (Pandas_nb) holding one array per column. Numeric columns are shared as views, so results written at compiled speed appear directly in your original DataFrame; and when compiled code genuinely needs pandas itself, a handle lets it call back into it.

The simplest solution that does the job is the best one. Other approaches are far heavier: Bodo and the archived Intel SDC register a whole DataFrame type and re‑implement pandas operations as full frameworks; Polars is an entirely separate engine with its own API to learn and your data to convert. Pandas Numba adds the least of all — a thin bridge over the pandas and numba you already use. There is no new DataFrame API, no framework to adopt, and nothing to port: you stay in ordinary pandas and hand just the columns you need into an @njit function, compiling the hot path when — and only when — you need the speed.

pip install pandas_numba