Skip to content

Commit dcdd00e

Browse files
author
=
committed
apply feedback
1 parent 9a90fa0 commit dcdd00e

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

pandas/core/apply.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ def apply(self) -> DataFrame | Series:
870870
"the 'numba' engine doesn't support using "
871871
"a string as the callable function"
872872
)
873-
if self.engine == "bodo":
873+
elif self.engine == "bodo":
874874
return self.apply_series_bodo()
875875

876876
return self.apply_str()
@@ -1057,13 +1057,17 @@ def apply_broadcast(self, target: DataFrame) -> DataFrame:
10571057
return result
10581058

10591059
def apply_standard(self):
1060-
if self.engine == "python":
1061-
results, res_index = self.apply_series_generator()
1062-
elif self.engine == "numba":
1060+
if self.engine == "numba":
10631061
results, res_index = self.apply_series_numba()
1064-
else:
1065-
# bodo engine
1062+
elif self.engine == "bodo":
10661063
return self.apply_series_bodo()
1064+
elif self.engine == "python":
1065+
results, res_index = self.apply_series_generator()
1066+
else:
1067+
raise ValueError(
1068+
"invalid value for engine, must be one "
1069+
"of {'python', 'numba', 'bodo'}"
1070+
)
10671071

10681072
# wrap results
10691073
return self.wrap_results(results, res_index)
@@ -1099,8 +1103,6 @@ def apply_series_numba(self):
10991103
return results, self.result_index
11001104

11011105
def apply_series_bodo(self) -> DataFrame | Series:
1102-
bodo = import_optional_dependency("bodo")
1103-
11041106
if self.result_type is not None:
11051107
raise NotImplementedError(
11061108
"the 'bodo' engine does not support result_type yet."
@@ -1111,6 +1113,8 @@ def apply_series_bodo(self) -> DataFrame | Series:
11111113
"the 'bodo' engine only supports axis=1 for user-defined functions."
11121114
)
11131115

1116+
bodo = import_optional_dependency("bodo")
1117+
11141118
@bodo.jit
11151119
def do_apply(obj, func, axis):
11161120
return obj.apply(func, axis)

pandas/tests/apply/test_bodo.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import pandas as pd
77
import pandas._testing as tm
88

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

1111

1212
def test_bodo_vs_python_indexing():
@@ -97,7 +97,9 @@ def test_bodo_result_type_unsupported():
9797
frame = pd.DataFrame(
9898
{"a": [1, 2, 3]},
9999
)
100-
f = lambda a: 1
100+
101+
def f(a):
102+
return 1
101103

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

0 commit comments

Comments
 (0)