@@ -112,12 +112,42 @@ def print_column(df, col):
112
112
method_signature = inspect .signature (method )
113
113
114
114
def inner (* args , ** kwargs ):
115
+ """Inner function to register the method.
116
+
117
+ This function is called when the user
118
+ decorates a function with register_dataframe_method.
119
+
120
+ Args:
121
+ *args: The arguments to pass to the registered method.
122
+ **kwargs: The keyword arguments to pass to the registered method.
123
+
124
+ Returns:
125
+ method: The original method.
126
+ """
127
+
115
128
class AccessorMethod (object ):
129
+ """DataFrame Accessor method class."""
130
+
116
131
def __init__ (self , pandas_obj ):
132
+ """Initialize the accessor method class.
133
+
134
+ Args:
135
+ pandas_obj (pandas.DataFrame): The pandas DataFrame object.
136
+ """
117
137
self ._obj = pandas_obj
118
138
119
139
@wraps (method )
120
140
def __call__ (self , * args , ** kwargs ):
141
+ """Call the accessor method.
142
+
143
+ Args:
144
+ *args: The arguments to pass to the registered method.
145
+ **kwargs: The keyword arguments to pass
146
+ to the registered method.
147
+
148
+ Returns:
149
+ object: The result of calling of the method.
150
+ """
121
151
global method_call_ctx_factory
122
152
if method_call_ctx_factory is None :
123
153
return method (self ._obj , * args , ** kwargs )
@@ -147,13 +177,30 @@ def register_series_method(method):
147
177
148
178
def inner (* args , ** kwargs ):
149
179
class AccessorMethod (object ):
180
+ """Series Accessor method class."""
181
+
150
182
__doc__ = method .__doc__
151
183
152
184
def __init__ (self , pandas_obj ):
185
+ """Initialize the accessor method class.
186
+
187
+ Args:
188
+ pandas_obj (pandas.Series): The pandas Series object.
189
+ """
153
190
self ._obj = pandas_obj
154
191
155
192
@wraps (method )
156
193
def __call__ (self , * args , ** kwargs ):
194
+ """Call the accessor method.
195
+
196
+ Args:
197
+ *args: The arguments to pass to the registered method.
198
+ **kwargs: The keyword arguments to pass
199
+ to the registered method.
200
+
201
+ Returns:
202
+ object: The result of calling of the method.
203
+ """
157
204
global method_call_ctx_factory
158
205
if method_call_ctx_factory is None :
159
206
return method (self ._obj , * args , ** kwargs )
0 commit comments