Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
RehanSD opened this issue Dec 2, 2021 · 0 comments · Fixed by #3765
Closed

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

RehanSD opened this issue Dec 2, 2021 · 0 comments · Fixed by #3765
Assignees
Labels
Backport 🔙 Issues that need to be backported to previous release(s) bug 🦗 Something isn't working P1 Important tasks that we should complete soon pandas concordance 🐼 Functionality that does not match pandas

Comments

@RehanSD
Copy link
Collaborator

RehanSD commented Dec 2, 2021

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 RehanSD self-assigned this Dec 2, 2021
@devin-petersohn devin-petersohn added the Backport 🔙 Issues that need to be backported to previous release(s) label Dec 6, 2021
@mvashishtha mvashishtha added the P1 Important tasks that we should complete soon label Aug 16, 2022
@mvashishtha mvashishtha added pandas concordance 🐼 Functionality that does not match pandas bug 🦗 Something isn't working labels Aug 30, 2022
@mvashishtha mvashishtha assigned billiam-wang and unassigned RehanSD Sep 14, 2022
@mvashishtha mvashishtha changed the title df.loc[max(df.index) + 1] = df.loc[any_number] raises an issue df.loc[max(df.index) + 1] = df.loc[any_number] raises KeyError Sep 16, 2022
billiam-wang added a commit to billiam-wang/modin that referenced this issue Sep 21, 2022
billiam-wang pushed a commit to billiam-wang/modin that referenced this issue Sep 26, 2022
…-like index is out of bounds

Signed-off-by: Rehan Durrani <rehan@ponder.io>
billiam-wang added a commit to billiam-wang/modin that referenced this issue Sep 26, 2022
…to df

Signed-off-by: Bill Wang <billiam@ponder.io>
billiam-wang added a commit to RehanSD/modin that referenced this issue Sep 28, 2022
…to df

Signed-off-by: Bill Wang <billiam@ponder.io>
mvashishtha pushed a commit that referenced this issue Oct 25, 2022
…3765)

Co-authored-by: Devin Petersohn <devin-petersohn@users.noreply.github.com>
Co-authored-by: Bill Wang <billiam@ponder.io>
Co-authored-by: Vasily Litvinov <fam1ly.n4me@yandex.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backport 🔙 Issues that need to be backported to previous release(s) bug 🦗 Something isn't working P1 Important tasks that we should complete soon pandas concordance 🐼 Functionality that does not match pandas
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants