@@ -262,13 +262,19 @@ def _register_accessor(name: str, cls):
262
262
The requirements for the accessor class are as follows:
263
263
264
264
* Must contain an init method that:
265
- * accepts a single {klass} object
266
- * raises an {AttributeError} if the {klass} object does not have correctly
265
+
266
+ * accepts a single {klass} object
267
+
268
+ * raises an AttributeError if the {klass} object does not have correctly
267
269
matching inputs for the accessor
270
+
268
271
* Must contain a method for each access pattern.
269
- * The methods should be able to take any argument signature.
270
- * Accessible using the @property decorator if no additional arguments are
272
+
273
+ * The methods should be able to take any argument signature.
274
+
275
+ * Accessible using the @property decorator if no additional arguments are
271
276
needed.
277
+
272
278
"""
273
279
274
280
def decorator (accessor ):
@@ -309,7 +315,9 @@ def sum(self):
309
315
310
316
311
317
Back in an interactive IPython session:
318
+
312
319
.. code-block:: ipython
320
+
313
321
>>> df = pd.DataFrame([[1, 2], ['x', 'y']])
314
322
>>> df.int_accessor
315
323
Traceback (most recent call last):
@@ -353,7 +361,9 @@ def sum(self):
353
361
354
362
355
363
Back in an interactive IPython session:
364
+
356
365
.. code-block:: ipython
366
+
357
367
>>> df = pd.Series([1, 2, 'x'])
358
368
>>> df.int_accessor
359
369
Traceback (most recent call last):
@@ -394,7 +404,9 @@ def even(self):
394
404
return [x for x in self._obj if x % 2 == 0]
395
405
396
406
Back in an interactive IPython session:
407
+
397
408
.. code-block:: ipython
409
+
398
410
>>> df = pd.DataFrame.from_dict({
399
411
'row1': {'1':1, '2':'a'},
400
412
'row2': {'1':2, '2':'b'}
0 commit comments