@@ -870,7 +870,7 @@ def apply(self) -> DataFrame | Series:
870
870
"the 'numba' engine doesn't support using "
871
871
"a string as the callable function"
872
872
)
873
- if self .engine == "bodo" :
873
+ elif self .engine == "bodo" :
874
874
return self .apply_series_bodo ()
875
875
876
876
return self .apply_str ()
@@ -1057,13 +1057,17 @@ def apply_broadcast(self, target: DataFrame) -> DataFrame:
1057
1057
return result
1058
1058
1059
1059
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" :
1063
1061
results , res_index = self .apply_series_numba ()
1064
- else :
1065
- # bodo engine
1062
+ elif self .engine == "bodo" :
1066
1063
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
+ )
1067
1071
1068
1072
# wrap results
1069
1073
return self .wrap_results (results , res_index )
@@ -1099,8 +1103,6 @@ def apply_series_numba(self):
1099
1103
return results , self .result_index
1100
1104
1101
1105
def apply_series_bodo (self ) -> DataFrame | Series :
1102
- bodo = import_optional_dependency ("bodo" )
1103
-
1104
1106
if self .result_type is not None :
1105
1107
raise NotImplementedError (
1106
1108
"the 'bodo' engine does not support result_type yet."
@@ -1111,6 +1113,8 @@ def apply_series_bodo(self) -> DataFrame | Series:
1111
1113
"the 'bodo' engine only supports axis=1 for user-defined functions."
1112
1114
)
1113
1115
1116
+ bodo = import_optional_dependency ("bodo" )
1117
+
1114
1118
@bodo .jit
1115
1119
def do_apply (obj , func , axis ):
1116
1120
return obj .apply (func , axis )
0 commit comments