From 242562108b099b4e7a205541ee15b9272dcb5265 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Fri, 9 Feb 2018 10:59:22 -0600 Subject: [PATCH] cleanup --- pandas/core/dtypes/cast.py | 2 +- pandas/core/indexes/category.py | 13 +------------ pandas/core/indexes/multi.py | 8 +++----- pandas/core/indexes/period.py | 5 ----- 4 files changed, 5 insertions(+), 23 deletions(-) diff --git a/pandas/core/dtypes/cast.py b/pandas/core/dtypes/cast.py index b2816343fc8eb..55919fb2bea0d 100644 --- a/pandas/core/dtypes/cast.py +++ b/pandas/core/dtypes/cast.py @@ -927,7 +927,7 @@ def try_timedelta(v): # will try first with a string & object conversion from pandas import to_timedelta try: - return to_timedelta(v)._values.reshape(shape) + return to_timedelta(v)._ndarray_values.reshape(shape) except Exception: return v.reshape(shape) diff --git a/pandas/core/indexes/category.py b/pandas/core/indexes/category.py index f03f8571121f0..5aa940499a368 100644 --- a/pandas/core/indexes/category.py +++ b/pandas/core/indexes/category.py @@ -1,6 +1,5 @@ import numpy as np from pandas._libs import index as libindex -from pandas._libs import join as libjoin from pandas import compat from pandas.compat.numpy import function as nv @@ -9,8 +8,6 @@ from pandas.core.dtypes.common import ( is_categorical_dtype, _ensure_platform_int, - _ensure_int32, - _ensure_int64, is_list_like, is_interval_dtype, is_scalar) @@ -217,14 +214,6 @@ def _shallow_copy(self, values=None, categories=None, ordered=None, values=values, categories=categories, ordered=ordered, **kwargs) - @cache_readonly - def _inner_indexer(self): - if self.codes.dtype.itemsize <= 4: - # int8, int16, int32 - return libjoin.inner_join_indexer_int32 - else: - return libjoin.inner_join_indexer_int64 - def _is_dtype_compat(self, other): """ *this is an internal non-public method* @@ -238,7 +227,7 @@ def _is_dtype_compat(self, other): """ if is_categorical_dtype(other): if isinstance(other, CategoricalIndex): - other = other.values + other = other._values if not other.is_dtype_equal(self): raise TypeError("categories must match existing categories " "when appending") diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index a257a1ba26128..907bbb2e8762e 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -2507,6 +2507,7 @@ def get_locs(self, seq): MultiIndex.slice_locs : Get slice location given start label(s) and end label(s). """ + from .numeric import Int64Index # must be lexsorted to at least as many levels true_slices = [i for (i, s) in enumerate(com.is_true_slices(seq)) if s] @@ -2532,7 +2533,6 @@ def _convert_to_indexer(r): "that is not the same length as the " "index") r = r.nonzero()[0] - from .numeric import Int64Index return Int64Index(r) def _update_indexer(idxr, indexer=indexer): @@ -2569,7 +2569,6 @@ def _update_indexer(idxr, indexer=indexer): if indexers is not None: indexer = _update_indexer(indexers, indexer=indexer) else: - from .numeric import Int64Index # no matches we are done return Int64Index([])._ndarray_values @@ -2652,9 +2651,8 @@ def equals(self, other): for i in range(self.nlevels): slabels = self.labels[i] slabels = slabels[slabels != -1] - svalues = algos.take_nd( - np.asarray(self.levels[i]._values), - slabels, allow_fill=False) + svalues = algos.take_nd(np.asarray(self.levels[i]._values), + slabels, allow_fill=False) olabels = other.labels[i] olabels = olabels[olabels != -1] diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index c8b7d6063e378..e90d3827fe84e 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -418,11 +418,6 @@ def _int64index(self): def values(self): return self.astype(object).values - @property - def _values(self): - # TODO: return PeriodArray - return self.values - @property def _ndarray_values(self): # Ordinals