pandas_numba
A tiny numba jitclass holding pandas-style typed columns for use inside @njit
nopython code — plus a pandas DataFrame bridge and objmode glue to call back into
pandas from jitted code.
Repository: https://github.com/quantaiko/Pandas_numba
Pandas_nb— ajitclassDataFrame-like container: one numpy array per column, keyed by title, one typed dict per element type.f_df_to_nb/f_nb_to_df(and friends) — the pandas bridge, module-level functions:DataFrame → Pandas_nband back, with columns shared as views where possible.f_eval_expr+ objmode — carry a DataFrame by handle and run pandas on the live frame from inside@njit.
Requirements
- Python 3.12
numpy,pandas,numba
Quick start
import pandas as pd
from numba import njit
from pandas_numba import f_df_to_nb, f_nb_to_np
df = pd.DataFrame({"a": [1., 2., 3.], "b": [1, 2, 3]}) # small dataframe
pandas_nb = f_df_to_nb(df) # columns shared as views
@njit
def f_update(pandas_nb):
pandas_nb.m_floats["a"][:] = pandas_nb.m_floats["a"] * 2 # df will be changed (shared view)
pandas_nb.f_add_int("c", pandas_nb.m_ints["b"] + 10) # new int column (built in nopython)
f_update(pandas_nb) # run in nopython mode
df["c"] = f_nb_to_np(pandas_nb, "c") # copy the new column back into df
print(df) # df is changed
# a b c
# 0 2.0 1 11
# 1 4.0 2 12
# 2 6.0 3 13
(The same script lives in simple_example.py.)
Calling Python (pandas) from a jitted function
A DataFrame has no numba type, so it cannot cross into nopython code. To run
real pandas from inside an @njit function, carry the frame by handle:
f_register_df(nb, df) stores df in a Python-side registry and writes its
int64 id into nb.m_df_id. Inside the jitted code, an objmode block hops
back into Python and f_eval_expr evaluates an expression string with np,
pd, the registry DF, and params (your Pandas_nb) in scope:
import pandas as pd
from numba import njit, objmode, float64
from pandas_numba import f_df_to_nb, f_register_df, f_eval_expr
df = pd.DataFrame({"x": [1.0, 2.0, 3.0, 4.0]})
nb = f_df_to_nb(df)
f_register_df(nb, df) # attach df by handle (sets nb.m_df_id)
@njit
def f_sum_via_pandas(nb):
with objmode(tot=float64): # hop from nopython back into Python
tot = f_eval_expr("float(DF[params.m_df_id]['x'].sum())", nb)
return tot
print(f_sum_via_pandas(nb)) # 10.0
Any pandas call is reachable this way, not just .sum(). Note objmode needs a
static output type (here float64), the registry holds df weakly (keep
your own reference alive while the handle is used), and each f_eval_expr round
trip costs on the order of ~15 µs, so it is for occasional calls, not hot loops.
Example data
simple_case_study.py generates a small top-of-book
order-book DataFrame (bid/ask prices and volumes over time) as a worked example
to feed through the bridge functions. f_make_book(n) scales it to n rows.
Documentation
See pandas_numba.md for the full data model, API, the
pandas round-trip rules, the df-by-handle / string-eval objmode mechanism, and
the numba constraints.
Tests
python -m pytest pandas_numba_tests.py -v
The suite is driven by one ALL_TYPES table — add a column type by adding one
row and every per-type test covers it.
License
MIT © 2026 Damien Loison
Metadata
Release files for pandas-numba 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pandas_numba-0.1.1.tar.gz | 11.6 kB | Without provenance | Details for pandas_numba-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pandas_numba-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for pandas_numba-0.1.1-py3-none-any.whl |
Total release size: 23.6 kB
Release files / pandas_numba-0.1.1.tar.gz
| Download URL | pandas_numba-0.1.1.tar.gz |
|---|---|
| Size | 11.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
07793c086a483f3b29a917ef98d129c89c04d3e5fca5c08a4a65ce69f31e1551
|
|
BLAKE2b-256 checksum How to use checksums |
c3cb0b80bf9acc023448d6cf9623ed5e41a7fb744a3c53cd2fd4b69f10b6009d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.7
|
Release files / pandas_numba-0.1.1-py3-none-any.whl
| Download URL | pandas_numba-0.1.1-py3-none-any.whl |
|---|---|
| Size | 12.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
39ffeefa1c70d07a56e6d28c99cfb9df3c6bedc63f88a9534d12777de1d82b2b
|
|
BLAKE2b-256 checksum How to use checksums |
68ce53e55dce8263d6d308304ec7a0ebd550fc64adc7ed1ea0473af6e447e34b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.7
|
Security for pandas-numba 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.