1
1
import ipdb
2
2
from functools import wraps
3
3
from pandas .api .extensions import register_series_accessor , register_dataframe_accessor
4
+ import inspect
4
5
from . import stack_counter
5
6
6
7
start_method_call = None
@@ -19,6 +20,8 @@ def print_column(df, col):
19
20
print(df[col])
20
21
"""
21
22
23
+ method_signature = inspect .signature (method )
24
+
22
25
def inner (* args , ** kwargs ):
23
26
class AccessorMethod (object ):
24
27
def __init__ (self , pandas_obj ):
@@ -34,12 +37,13 @@ def __call__(self, *args, **kwargs):
34
37
stack_depth = sc .scf .level
35
38
if stack_depth == 1 :
36
39
if start_method_call :
37
- method_call_obj = start_method_call (self ._obj , method .__name__ , args , kwargs , stack_depth )
40
+ #ipdb.set_trace()
41
+ method_call_obj = start_method_call (self ._obj , method .__name__ , method_signature , args , kwargs , stack_depth )
38
42
ret = method (self ._obj , * args , ** kwargs )
39
43
elif stack_depth == 2 and method .__name__ == 'copy' :
40
44
#ipdb.set_trace()
41
45
if start_method_call :
42
- method_call_obj = start_method_call (self ._obj , method .__name__ , args , kwargs , stack_depth )
46
+ method_call_obj = start_method_call (self ._obj , method .__name__ , method_signature , args , kwargs , stack_depth )
43
47
ret = method (self ._obj , * args , ** kwargs )
44
48
else :
45
49
ret = method (self ._obj , * args , ** kwargs )
@@ -59,6 +63,8 @@ def __call__(self, *args, **kwargs):
59
63
def register_series_method (method ):
60
64
"""Register a function as a method attached to the Pandas Series."""
61
65
66
+ method_signature = inspect .signature (method )
67
+
62
68
def inner (* args , ** kwargs ):
63
69
class AccessorMethod (object ):
64
70
__doc__ = method .__doc__
@@ -74,7 +80,7 @@ def __call__(self, *args, **kwargs):
74
80
if stack_depth <= 2 :
75
81
global start_method_call
76
82
if start_method_call :
77
- method_call_obj = start_method_call (self ._obj , method .__name__ , args , kwargs , stack_depth )
83
+ method_call_obj = start_method_call (self ._obj , method .__name__ , method_signature , args , kwargs , stack_depth )
78
84
79
85
ret = method (self ._obj , * args , ** kwargs )
80
86
0 commit comments