diff --git a/doc/source/reference/indexing.rst b/doc/source/reference/indexing.rst index dd59a99b3df9e..409791c7530a2 100644 --- a/doc/source/reference/indexing.rst +++ b/doc/source/reference/indexing.rst @@ -93,7 +93,6 @@ Compatibility with MultiIndex :toctree: api/ Index.set_names - Index.is_lexsorted_for_tuple Index.droplevel Missing values diff --git a/doc/source/whatsnew/v1.0.0.rst b/doc/source/whatsnew/v1.0.0.rst index 2e2c5281e6752..f9cecd662e545 100644 --- a/doc/source/whatsnew/v1.0.0.rst +++ b/doc/source/whatsnew/v1.0.0.rst @@ -256,6 +256,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more. - Ability to read pickles containing :class:`Categorical` instances created with pre-0.16 version of pandas has been removed (:issue:`27538`) - Removed the previously deprecated ``reduce`` and ``broadcast`` arguments from :meth:`DataFrame.apply` (:issue:`18577`) - Removed the previously deprecated ``assert_raises_regex`` function in ``pandas.util.testing`` (:issue:`29174`) +- Removed :meth:`Index.is_lexsorted_for_tuple` (:issue:`29305`) - .. _whatsnew_1000.performance: diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 187c7e2f3a7f7..301426d237d19 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -1726,9 +1726,6 @@ def _is_strictly_monotonic_decreasing(self): """ return self.is_unique and self.is_monotonic_decreasing - def is_lexsorted_for_tuple(self, tup): - return True - @cache_readonly def is_unique(self): """ diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py index 44c786f003369..7db54f4305c2e 100755 --- a/pandas/core/indexing.py +++ b/pandas/core/indexing.py @@ -101,7 +101,6 @@ class IndexingError(Exception): class _NDFrameIndexer(_NDFrameIndexerBase): _valid_types = None # type: str - _exception = Exception axis = None def __call__(self, axis=None): @@ -881,14 +880,6 @@ def _handle_lowerdim_multi_index_axis0(self, tup: Tuple): # else IndexingError will be raised if len(tup) <= self.obj.index.nlevels and len(tup) > self.ndim: raise ek - except Exception as e1: - if isinstance(tup[0], (slice, Index)): - raise IndexingError("Handle elsewhere") - - # raise the error if we are not sorted - ax0 = self.obj._get_axis(0) - if not ax0.is_lexsorted_for_tuple(tup): - raise e1 return None @@ -1385,8 +1376,6 @@ def _convert_for_reindex(self, key, axis: int): class _LocationIndexer(_NDFrameIndexer): - _exception = Exception - def __getitem__(self, key): if type(key) is tuple: key = tuple(com.apply_if_callable(x, self.obj) for x in key) @@ -1417,10 +1406,7 @@ def _getbool_axis(self, key, axis: int): labels = self.obj._get_axis(axis) key = check_bool_indexer(labels, key) inds = key.nonzero()[0] - try: - return self.obj.take(inds, axis=axis) - except Exception as detail: - raise self._exception(detail) + return self.obj.take(inds, axis=axis) def _get_slice_axis(self, slice_obj: slice, axis: int): """ this is pretty simple as we just have to deal with labels """ @@ -1685,7 +1671,6 @@ class _LocIndexer(_LocationIndexer): "endpoints included! Can be slices of integers if the " "index is integers), listlike of labels, boolean" ) - _exception = KeyError @Appender(_NDFrameIndexer._validate_key.__doc__) def _validate_key(self, key, axis: int): @@ -1970,7 +1955,6 @@ class _iLocIndexer(_LocationIndexer): "integer, integer slice (START point is INCLUDED, END " "point is EXCLUDED), listlike of integers, boolean array" ) - _exception = IndexError _get_slice_axis = _NDFrameIndexer._get_slice_axis def _validate_key(self, key, axis: int):