Skip to content

Commit 6f4fb50

Browse files
committed
Updated engine handling: normalizing numba to a fake decorator and updating empty or python string condition
1 parent 545db65 commit 6f4fb50

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

pandas/core/frame.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
roperator,
130130
)
131131
from pandas.core.accessor import Accessor
132-
from pandas.core.apply import reconstruct_and_relabel_result
132+
from pandas.core.apply import NumbaExecutionEngine, reconstruct_and_relabel_result
133133
from pandas.core.array_algos.take import take_2d_multi
134134
from pandas.core.arraylike import OpsMixin
135135
from pandas.core.arrays import (
@@ -10616,14 +10616,14 @@ def apply(
1061610616
significant amount of time to run. Fast functions are unlikely to run faster
1061710617
with JIT compilation.
1061810618
"""
10619-
if engine is None or isinstance(engine, str):
10620-
from pandas.core.apply import frame_apply
10621-
10622-
if engine is None:
10623-
engine = "python"
10619+
if engine == "numba":
10620+
numba = import_optional_dependency("numba")
10621+
numba_jit = numba.jit(**engine_kwargs)
10622+
numba_jit.__pandas_udf__ = NumbaExecutionEngine
10623+
engine = numba_jit
1062410624

10625-
if engine not in ["python", "numba"]:
10626-
raise ValueError(f"Unknown engine '{engine}'")
10625+
if engine is None or engine == "python":
10626+
from pandas.core.apply import frame_apply
1062710627

1062810628
op = frame_apply(
1062910629
self,
@@ -10632,7 +10632,7 @@ def apply(
1063210632
raw=raw,
1063310633
result_type=result_type,
1063410634
by_row=by_row,
10635-
engine=engine,
10635+
engine="python",
1063610636
engine_kwargs=engine_kwargs,
1063710637
args=args,
1063810638
kwargs=kwargs,

0 commit comments

Comments
 (0)