2
2
This file is here as an example, this code will live in the Numba and
3
3
Bodo libraries.
4
4
"""
5
+
5
6
from __future__ import annotations
6
- from collections .abc import Callable
7
- from typing import TYPE_CHECKING , Literal , Any
8
7
9
- import pandas as pd
8
+ from typing import (
9
+ TYPE_CHECKING ,
10
+ Any ,
11
+ Literal ,
12
+ )
13
+
10
14
import bodo
11
15
16
+ import pandas as pd
17
+
12
18
if TYPE_CHECKING :
13
- from pandas ._typing import Axis , AggFuncType
19
+ from collections .abc import Callable
20
+
21
+ from pandas ._typing import (
22
+ AggFuncType ,
23
+ Axis ,
24
+ )
25
+
14
26
15
27
def __pandas_udf__ (
16
28
jit_decorator : Callable ,
@@ -24,17 +36,14 @@ def __pandas_udf__(
24
36
kwargs : dict [str , Any ],
25
37
by_row : Literal [False , "compat" ],
26
38
):
27
-
28
39
if isinstance (obj , pd .DataFrame ) and method == "apply" :
29
40
if result_type is not None :
30
41
raise NotImplementedError (
31
42
"engine='bodo' not supported when result_type is not None"
32
43
)
33
44
34
45
if raw :
35
- raise NotImplementedError (
36
- "engine='bodo' not supported when raw=True"
37
- )
46
+ raise NotImplementedError ("engine='bodo' not supported when raw=True" )
38
47
if isinstance (func , str ) and axis != 1 :
39
48
raise NotImplementedError (
40
49
"engine='bodo' only supports axis=1 when func is the name of a "
@@ -44,14 +53,16 @@ def __pandas_udf__(
44
53
raise NotImplementedError (
45
54
"engine='bodo' not supported when args or kwargs are specified"
46
55
)
56
+
47
57
@jit_decorator
48
58
def jit_func (df , func , axis ):
49
59
return df .apply (func , axis = axis )
50
60
51
61
return jit_func (obj , func , axis )
52
62
else :
53
63
raise NotImplementedError (
54
- f"engine='bodo' not supported for { obj .__class__ . __name__ } .{ method } "
64
+ f"engine='bodo' not supported for { obj .__name__ } .{ method } "
55
65
)
56
66
67
+
57
68
bodo .jit .__pandas_udf__ = __pandas_udf__
0 commit comments