Skip to content

Commit

Permalink
REFACTOR-#1938: avoid index access in a simple column reference (#1939)
Browse files Browse the repository at this point in the history
Signed-off-by: ienkovich <ilya.enkovich@intel.com>
  • Loading branch information
ienkovich committed Aug 21, 2020
1 parent a1fa46a commit 36106b4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions modin/pandas/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3442,9 +3442,14 @@ def __getitem__(self, key):
return self._default_to_pandas("__getitem__", key)
# see if we can slice the rows
# This lets us reuse code in Pandas to error check
indexer = convert_to_index_sliceable(
getattr(pandas, type(self).__name__)(index=self.index), key
)
indexer = None
if isinstance(key, slice) or (
isinstance(key, str)
and (not hasattr(self, "columns") or key not in self.columns)
):
indexer = convert_to_index_sliceable(
getattr(pandas, type(self).__name__)(index=self.index), key
)
if indexer is not None:
return self._getitem_slice(indexer)
else:
Expand Down

0 comments on commit 36106b4

Please sign in to comment.