MCPcopy
hub / github.com/pandas-dev/pandas / _internal_get_values

Method _internal_get_values

pandas/core/arrays/categorical.py:1939–1960  ·  view source on GitHub ↗

Return the values. For internal compatibility with pandas formatting. Returns ------- np.ndarray or ExtensionArray A numpy array or ExtensionArray of the same dtype as categorical.categories.dtype.

(self)

Source from the content-addressed store, hash-verified

1937 return arr._from_backing_data(backing)
1938
1939 def _internal_get_values(self) -> ArrayLike:
1940 """
1941 Return the values.
1942
1943 For internal compatibility with pandas formatting.
1944
1945 Returns
1946 -------
1947 np.ndarray or ExtensionArray
1948 A numpy array or ExtensionArray of the same dtype as
1949 categorical.categories.dtype.
1950 """
1951 # if we are a datetime and period index, return Index to keep metadata
1952 if needs_i8_conversion(self.categories.dtype):
1953 return self.categories.take(self._codes, fill_value=NaT)._values
1954 elif is_integer_dtype(self.categories.dtype) and -1 in self._codes:
1955 return (
1956 self.categories.astype("object")
1957 .take(self._codes, fill_value=np.nan)
1958 ._values
1959 )
1960 return np.array(self)
1961
1962 def check_for_ordered(self, op) -> None:
1963 """assert that we are ordered"""

Callers 5

__iter__Method · 0.95
_get_values_reprMethod · 0.95
_validate_listlikeMethod · 0.80
_valuesMethod · 0.80
_format_stringsMethod · 0.80

Calls 5

needs_i8_conversionFunction · 0.90
is_integer_dtypeFunction · 0.90
takeMethod · 0.45
astypeMethod · 0.45
arrayMethod · 0.45

Tested by

no test coverage detected