|
1 | | -from pathlib import Path |
2 | 1 | from types import FunctionType, LambdaType, MethodType |
3 | 2 |
|
4 | 3 | import numpy as np |
@@ -42,11 +41,12 @@ def __getattr__(self, attr): |
42 | 41 |
|
43 | 42 | apply_series = self._obj.to_series() if isinstance(self._obj, pd.Index) else self._obj |
44 | 43 |
|
45 | | - # check the type of this attribute on a Path object |
| 44 | + # check the type of this attribute on a Path object (we need an actual instance) since |
| 45 | + # the super classes dispatch |
46 | 46 | if isinstance(self._obj.values[0], path_class): |
47 | 47 | attr_type = getattr(type(self._obj.values[0]), attr, None) |
48 | 48 | else: |
49 | | - attr_type = getattr(type(self._to_path_object("")), attr, None) |
| 49 | + attr_type = getattr(type(self._to_path_object(self._obj.values[0])), attr, None) |
50 | 50 |
|
51 | 51 | # if we're asking for a property, do the calculation and return the result |
52 | 52 | if isinstance(attr_type, property): |
@@ -137,7 +137,3 @@ def register_path_accessor(accessor_name, path_class, *args, **kwargs): |
137 | 137 |
|
138 | 138 | pd.api.extensions.register_series_accessor(accessor_name)(accessor_class) |
139 | 139 | pd.api.extensions.register_index_accessor(accessor_name)(accessor_class) |
140 | | - |
141 | | - |
142 | | -# default to registering `Path` to `path` |
143 | | -register_path_accessor("path", Path) |
0 commit comments