Skip to content

REF: Remove CategoricalIndex.get_value #31765

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Feb 9, 2020
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 1 addition & 33 deletions pandas/core/indexes/category.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import TYPE_CHECKING, Any, List
from typing import Any, List
import warnings

import numpy as np
Expand Down Expand Up @@ -29,9 +29,6 @@
from pandas.core.indexes.extension import ExtensionIndex, inherit_names
import pandas.core.missing as missing

if TYPE_CHECKING:
from pandas import Series

_index_doc_kwargs = dict(ibase._index_doc_kwargs)
_index_doc_kwargs.update(dict(target_klass="CategoricalIndex"))

Expand Down Expand Up @@ -444,35 +441,6 @@ def _maybe_cast_indexer(self, key):
code = self.codes.dtype.type(code)
return code

def get_value(self, series: "Series", key: Any):
"""
Fast lookup of value from 1-dimensional ndarray. Only use this if you
know what you're doing

Parameters
----------
series : Series
1-dimensional array to take values from
key: : scalar
The value of this index at the position of the desired value,
otherwise the positional index of the desired value

Returns
-------
Any
The element of the series at the position indicated by the key
"""
k = key
try:
k = self._convert_scalar_indexer(k, kind="getitem")
indexer = self.get_loc(k)
return series.take([indexer])[0]
except (KeyError, TypeError):
pass

# we might be a positional inexer
return Index.get_value(self, series, key)

@Appender(Index.where.__doc__)
def where(self, cond, other=None):
# TODO: Investigate an alternative implementation with
Expand Down
3 changes: 3 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,9 @@ def _get_value(self, label, takeable: bool = False):
"""
if takeable:
return self._values[label]

# We assume that _convert_scalar_indexer has already been called,
# with kind="loc", if necessary, by the time we get here
return self.index.get_value(self, label)

def __setitem__(self, key, value):
Expand Down