File tree Expand file tree Collapse file tree 1 file changed +25
-11
lines changed Expand file tree Collapse file tree 1 file changed +25
-11
lines changed Original file line number Diff line number Diff line change 13
13
cast ,
14
14
)
15
15
16
- import numba
17
16
import numpy as np
18
17
19
18
from pandas ._libs .internals import BlockValuesRefs
@@ -1149,16 +1148,31 @@ def wrapper(*args, **kwargs):
1149
1148
return wrapper
1150
1149
1151
1150
if engine == "numba" :
1152
- if not hasattr (numba .jit , "__pandas_udf__" ):
1153
- numba .jit .__pandas_udf__ = NumbaExecutionEngine
1154
- result = numba .jit .__pandas_udf__ .apply (
1155
- self .values ,
1156
- self .func ,
1157
- self .args ,
1158
- self .kwargs ,
1159
- engine_kwargs ,
1160
- self .axis ,
1161
- )
1151
+ try :
1152
+ import numba
1153
+
1154
+ if not hasattr (numba .jit , "__pandas_udf__" ):
1155
+ numba .jit .__pandas_udf__ = NumbaExecutionEngine
1156
+ result = numba .jit .__pandas_udf__ .apply (
1157
+ self .values ,
1158
+ self .func ,
1159
+ self .args ,
1160
+ self .kwargs ,
1161
+ engine_kwargs ,
1162
+ self .axis ,
1163
+ )
1164
+ else :
1165
+ raise ImportError
1166
+ except ImportError :
1167
+ engine_obj = NumbaExecutionEngine ()
1168
+ result = engine_obj .apply (
1169
+ self .values ,
1170
+ self .func ,
1171
+ self .args ,
1172
+ self .kwargs ,
1173
+ engine_kwargs ,
1174
+ self .axis ,
1175
+ )
1162
1176
else :
1163
1177
result = np .apply_along_axis (
1164
1178
wrap_function (self .func ),
You can’t perform that action at this time.
0 commit comments