modin icon indicating copy to clipboard operation
modin copied to clipboard

df.loc[max(df.index) + 1] = df.loc[any_number] raises KeyError

Open RehanSD opened this issue 3 years ago • 0 comments

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
  • Modin version (modin.__version__):
  • Python version:
  • Code we can use to reproduce:

Describe the problem

When we do the following in pandas:

df = pd.DataFrame([[1, 2, 3], [3, 4, 5]])
df.loc[2] = df.loc[1]

df becomes

   0  1  2
0  1  2  3
1  3  4  5
2  3  4  5

When we do it Modin, the following happens:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-3-8988af25de4f> in <module>
      1 df = pd.DataFrame([[1, 2, 3], [3, 4, 5]])
----> 2 df.loc[2] = df.loc[1]

~/Documents/modin/modin/pandas/indexing.py in __setitem__(self, key, item)
    713             self.qc = self.df._query_compiler
    714         else:
--> 715             row_lookup, col_lookup = self._compute_lookup(row_loc, col_loc)
    716             super(_LocIndexer, self).__setitem__(
    717                 row_lookup,

~/Documents/modin/modin/pandas/indexing.py in _compute_lookup(self, row_loc, col_loc)
    840                         else axis_loc
    841                     )
--> 842                     raise KeyError(missing_labels)
    843
    844             if isinstance(axis_lookup, pandas.Index) and not is_range_like(axis_lookup):

KeyError: array([2])

(we get a KeyError since we're trying to index into an index position that doesn't exist)

Source code / logs

RehanSD avatar Dec 02 '21 02:12 RehanSD