Skip to content

Commit 65b9d32

Browse files
committed
Fixed CI, removed unused numba checks, updated raw=false condition, updated engine checks
1 parent ed8dc7f commit 65b9d32

File tree

2 files changed

+23
-33
lines changed

2 files changed

+23
-33
lines changed

pandas/core/apply.py

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,12 @@ def apply(
230230
# check for data typing
231231
if not isinstance(data, np.ndarray):
232232
if len(data.columns) == 0 and len(data.index) == 0:
233-
return data.copy() # mimic apply_empty_result()
234-
return FrameApply.apply_standard()
233+
return data.copy() # mimic apply_empty_result()
234+
# TODO:
235+
# Rewrite FrameApply.apply_series_numba() logic without FrameApply object
236+
raise NotImplementedError(
237+
"raw=False is not yet supported in NumbaExecutionEngine."
238+
)
235239

236240
engine_kwargs: dict[str, bool] | None = (
237241
decorator if isinstance(decorator, dict) else None
@@ -780,12 +784,6 @@ def apply_list_or_dict_like(self) -> DataFrame | Series:
780784
Result when self.func is a list-like or dict-like, None otherwise.
781785
"""
782786

783-
if self.engine == "numba":
784-
raise NotImplementedError(
785-
"The 'numba' engine doesn't support list-like/"
786-
"dict likes of callables yet."
787-
)
788-
789787
if self.axis == 1 and isinstance(self.obj, ABCDataFrame):
790788
return self.obj.T.apply(self.func, 0, args=self.args, **self.kwargs).T
791789

@@ -1153,28 +1151,13 @@ def wrapper(*args, **kwargs):
11531151

11541152
return wrapper
11551153

1156-
if engine == "numba":
1157-
numba = import_optional_dependency("numba")
1158-
1159-
if not hasattr(numba.jit, "__pandas_udf__"):
1160-
numba.jit.__pandas_udf__ = NumbaExecutionEngine
1161-
1162-
result = numba.jit.__pandas_udf__.apply(
1163-
self.values,
1164-
self.func,
1165-
self.args,
1166-
self.kwargs,
1167-
engine_kwargs,
1168-
self.axis,
1169-
)
1170-
else:
1171-
result = np.apply_along_axis(
1172-
wrap_function(self.func),
1173-
self.axis,
1174-
self.values,
1175-
*self.args,
1176-
**self.kwargs,
1177-
)
1154+
result = np.apply_along_axis(
1155+
wrap_function(self.func),
1156+
self.axis,
1157+
self.values,
1158+
*self.args,
1159+
**self.kwargs,
1160+
)
11781161

11791162
# TODO: mixed type case
11801163
if result.ndim == 2:

pandas/core/frame.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@
129129
roperator,
130130
)
131131
from pandas.core.accessor import Accessor
132-
from pandas.core.apply import NumbaExecutionEngine, reconstruct_and_relabel_result
132+
from pandas.core.apply import (
133+
NumbaExecutionEngine,
134+
reconstruct_and_relabel_result,
135+
)
133136
from pandas.core.array_algos.take import take_2d_multi
134137
from pandas.core.arraylike import OpsMixin
135138
from pandas.core.arrays import (
@@ -10625,9 +10628,12 @@ def apply(
1062510628
numba_jit.__pandas_udf__ = NumbaExecutionEngine
1062610629
engine = numba_jit
1062710630

10628-
if engine is None or engine == "python":
10631+
if engine is None or isinstance(engine, str):
1062910632
from pandas.core.apply import frame_apply
1063010633

10634+
if engine not in ["python"] and engine is not None:
10635+
raise ValueError(f"Unknown engine '{engine}'")
10636+
1063110637
op = frame_apply(
1063210638
self,
1063310639
func=func,
@@ -10641,7 +10647,8 @@ def apply(
1064110647
kwargs=kwargs,
1064210648
)
1064310649
return op.apply().__finalize__(self, method="apply")
10644-
elif hasattr(engine, "__pandas_udf__"):
10650+
10651+
if hasattr(engine, "__pandas_udf__"):
1064510652
if result_type is not None:
1064610653
raise NotImplementedError(
1064710654
f"{result_type=} only implemented for the default engine"

0 commit comments

Comments
 (0)