Skip to content

Commit

Permalink
apply feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Jan 17, 2025
1 parent 9a90fa0 commit dcdd00e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
20 changes: 12 additions & 8 deletions pandas/core/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ def apply(self) -> DataFrame | Series:
"the 'numba' engine doesn't support using "
"a string as the callable function"
)
if self.engine == "bodo":
elif self.engine == "bodo":
return self.apply_series_bodo()

return self.apply_str()
Expand Down Expand Up @@ -1057,13 +1057,17 @@ def apply_broadcast(self, target: DataFrame) -> DataFrame:
return result

def apply_standard(self):
if self.engine == "python":
results, res_index = self.apply_series_generator()
elif self.engine == "numba":
if self.engine == "numba":
results, res_index = self.apply_series_numba()
else:
# bodo engine
elif self.engine == "bodo":
return self.apply_series_bodo()
elif self.engine == "python":
results, res_index = self.apply_series_generator()
else:
raise ValueError(
"invalid value for engine, must be one "
"of {'python', 'numba', 'bodo'}"
)

# wrap results
return self.wrap_results(results, res_index)
Expand Down Expand Up @@ -1099,8 +1103,6 @@ def apply_series_numba(self):
return results, self.result_index

def apply_series_bodo(self) -> DataFrame | Series:
bodo = import_optional_dependency("bodo")

if self.result_type is not None:
raise NotImplementedError(
"the 'bodo' engine does not support result_type yet."
Expand All @@ -1111,6 +1113,8 @@ def apply_series_bodo(self) -> DataFrame | Series:
"the 'bodo' engine only supports axis=1 for user-defined functions."
)

bodo = import_optional_dependency("bodo")

@bodo.jit
def do_apply(obj, func, axis):
return obj.apply(func, axis)
Expand Down
6 changes: 4 additions & 2 deletions pandas/tests/apply/test_bodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pandas as pd
import pandas._testing as tm

pytestmark = [pytest.mark.skip, td.skip_if_no("bodo")]
pytestmark = [pytest.mark.single_cpu, td.skip_if_no("bodo")]


def test_bodo_vs_python_indexing():
Expand Down Expand Up @@ -97,7 +97,9 @@ def test_bodo_result_type_unsupported():
frame = pd.DataFrame(
{"a": [1, 2, 3]},
)
f = lambda a: 1

def f(a):
return 1

with pytest.raises(
NotImplementedError, match="the 'bodo' engine does not support result_type yet."
Expand Down

0 comments on commit dcdd00e

Please sign in to comment.