|
15 | 15 | from pandas.core.dtypes.common import (
|
16 | 16 | ensure_object, is_bool_dtype, is_categorical_dtype, is_integer,
|
17 | 17 | is_list_like, is_object_dtype, is_re, is_scalar, is_string_like)
|
18 |
| -from pandas.core.dtypes.generic import ABCIndex, ABCSeries |
| 18 | +from pandas.core.dtypes.generic import ABCIndexClass, ABCSeries |
19 | 19 | from pandas.core.dtypes.missing import isna
|
20 | 20 |
|
21 | 21 | from pandas.core.algorithms import take_1d
|
@@ -931,7 +931,7 @@ def str_extractall(arr, pat, flags=0):
|
931 | 931 | if regex.groups == 0:
|
932 | 932 | raise ValueError("pattern contains no capture groups")
|
933 | 933 |
|
934 |
| - if isinstance(arr, ABCIndex): |
| 934 | + if isinstance(arr, ABCIndexClass): |
935 | 935 | arr = arr.to_series().reset_index(drop=True)
|
936 | 936 |
|
937 | 937 | names = dict(zip(regex.groupindex.values(), regex.groupindex.keys()))
|
@@ -1854,15 +1854,16 @@ def __iter__(self):
|
1854 | 1854 | def _wrap_result(self, result, use_codes=True,
|
1855 | 1855 | name=None, expand=None, fill_value=np.nan):
|
1856 | 1856 |
|
1857 |
| - from pandas.core.index import Index, MultiIndex |
| 1857 | + from pandas import Index, Series, MultiIndex |
1858 | 1858 |
|
1859 | 1859 | # for category, we do the stuff on the categories, so blow it up
|
1860 | 1860 | # to the full series again
|
1861 | 1861 | # But for some operations, we have to do the stuff on the full values,
|
1862 | 1862 | # so make it possible to skip this step as the method already did this
|
1863 | 1863 | # before the transformation...
|
1864 | 1864 | if use_codes and self._is_categorical:
|
1865 |
| - result = take_1d(result, self._orig.cat.codes, |
| 1865 | + # if self._orig is a CategoricalIndex, there is no .cat-accessor |
| 1866 | + result = take_1d(result, Series(self._orig, copy=False).cat.codes, |
1866 | 1867 | fill_value=fill_value)
|
1867 | 1868 |
|
1868 | 1869 | if not hasattr(result, 'ndim') or not hasattr(result, 'dtype'):
|
|
0 commit comments