Skip to content

Commit

Permalink
FIX-modin-project#3764: Amend first if statement to check if not list…
Browse files Browse the repository at this point in the history
…-like index is out of bounds

Signed-off-by: Rehan Durrani <[email protected]>
  • Loading branch information
RehanSD authored and billiam-wang committed Sep 22, 2022
1 parent b5f7ed3 commit c4cc308
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions modin/pandas/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,11 +765,15 @@ def _loc(df):
)
return
row_loc, col_loc, _ = self._parse_row_and_column_locators(key)
if isinstance(row_loc, list) and len(row_loc) == 1:
if row_loc[0] not in self.qc.index:
index = self.qc.index.insert(len(self.qc.index), row_loc[0])
self.qc = self.qc.reindex(labels=index, axis=0)
self.df._update_inplace(new_query_compiler=self.qc)
if (
isinstance(row_loc, list)
and len(row_loc) == 1
and row_loc[0] not in self.qc.index
) or (isinstance(row_loc, int) and row_loc not in self.qc.index):
row_loc = row_loc[0] if isinstance(row_loc, list) else row_loc
index = self.qc.index.insert(len(self.qc.index), row_loc)
self.qc = self.qc.reindex(labels=index, axis=0)
self.df._update_inplace(new_query_compiler=self.qc)

if (
isinstance(col_loc, list)
Expand Down

0 comments on commit c4cc308

Please sign in to comment.