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

Method _get_values_tuple

pandas/core/series.py:1005–1023  ·  view source on GitHub ↗
(self, key: tuple)

Source from the content-addressed store, hash-verified

1003 return self.loc[key]
1004
1005 def _get_values_tuple(self, key: tuple):
1006 # mpl hackaround
1007 if com.any_none(*key):
1008 # mpl compat if we look up e.g. ser[:, np.newaxis];
1009 # see tests.series.timeseries.test_mpl_compat_hack
1010 # the asarray is needed to avoid returning a 2D DatetimeArray
1011 result = np.asarray(self._values[key])
1012 disallow_ndim_indexing(result)
1013 return result
1014
1015 if not isinstance(self.index, MultiIndex):
1016 raise KeyError("key of type tuple not found and not a MultiIndex")
1017
1018 # If key is contained, would have returned by now
1019 indexer, new_index = self.index.get_loc_level(key)
1020 new_ser = self._constructor(self._values[indexer], index=new_index, copy=False)
1021 if isinstance(indexer, slice):
1022 new_ser._mgr.add_references(self._mgr)
1023 return new_ser.__finalize__(self)
1024
1025 def _get_rows_with_mask(self, indexer: npt.NDArray[np.bool_]) -> Series:
1026 new_mgr = self._mgr.get_rows_with_mask(indexer)

Callers 2

__getitem__Method · 0.95
_get_withMethod · 0.95

Calls 5

_constructorMethod · 0.95
disallow_ndim_indexingFunction · 0.90
get_loc_levelMethod · 0.80
add_referencesMethod · 0.80
__finalize__Method · 0.80

Tested by

no test coverage detected