Skip to main content

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 — a jitclass DataFrame-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_nb and 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.)

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.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pandas-numba 0.1.0
File Size Uploaded
pandas_numba-0.1.0.tar.gz 11.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pandas-numba 0.1.0
File Interpreter ABI Platform
pandas_numba-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.6 kB

Release files / pandas_numba-0.1.0.tar.gz

Download URL pandas_numba-0.1.0.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7a4c85b9c0ba09b3b5b3760d257dd269a71fce1aa458673ea685233b3c7bd5d2
BLAKE2b-256 checksum
How to use checksums
c30f2e3f3951b4386cc40730eee23640b55c36dcb87c4079f617cac12e4ae239
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.0-py3-none-any.whl

Download URL pandas_numba-0.1.0-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4162a2336638a4c9c61b1b5e0c28a92563ee423e8233506d984a1563a275d180
BLAKE2b-256 checksum
How to use checksums
d99ddb538ada9034a21e54c86545c5428e8a8ef99490aa5ea4e119839bfe465f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.7

Release history Release notifications | RSS feed

0.1.1

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page