A DataFrame has no numba type, so it cannot cross into nopython code.
Carry it by handle: f_register_df(nb, df) stores it in a
Python-side registry and writes its id into nb.m_df_id. Inside the jitted code
an objmode block hops back into Python and f_eval_expr runs any
pandas call on the live frame.
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