Skip to content

Commit 88c17ee

Browse files
committed
added method signature member to be passed to the callback handling method call
1 parent 5c753b4 commit 88c17ee

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

pandas_flavor/register.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import ipdb
22
from functools import wraps
33
from pandas.api.extensions import register_series_accessor, register_dataframe_accessor
4+
import inspect
45
from . import stack_counter
56

67
start_method_call = None
@@ -19,6 +20,8 @@ def print_column(df, col):
1920
print(df[col])
2021
"""
2122

23+
method_signature = inspect.signature(method)
24+
2225
def inner(*args, **kwargs):
2326
class AccessorMethod(object):
2427
def __init__(self, pandas_obj):
@@ -34,12 +37,13 @@ def __call__(self, *args, **kwargs):
3437
stack_depth = sc.scf.level
3538
if stack_depth == 1:
3639
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)
3842
ret = method(self._obj, *args, **kwargs)
3943
elif stack_depth == 2 and method.__name__ == 'copy':
4044
#ipdb.set_trace()
4145
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)
4347
ret = method(self._obj, *args, **kwargs)
4448
else:
4549
ret = method(self._obj, *args, **kwargs)
@@ -59,6 +63,8 @@ def __call__(self, *args, **kwargs):
5963
def register_series_method(method):
6064
"""Register a function as a method attached to the Pandas Series."""
6165

66+
method_signature = inspect.signature(method)
67+
6268
def inner(*args, **kwargs):
6369
class AccessorMethod(object):
6470
__doc__ = method.__doc__
@@ -74,7 +80,7 @@ def __call__(self, *args, **kwargs):
7480
if stack_depth <= 2:
7581
global start_method_call
7682
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)
7884

7985
ret = method(self._obj, *args, **kwargs)
8086

0 commit comments

Comments
 (0)