Skip to content

BUG: fix: list as index item does not raise #61674

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Andre-Andreati
Copy link

Problem:

Index constructor was allowing creation of indexes where one of the index's item is a list (unhashable) while others are not lists.

  • If all items are lists - like columns=[ ['a', 'b'], ['b', 'c'], ['b', 'c'] ], it will try to create a MultiIndex. Correct.
  • If any item is a list, but NOT all - like the initial example, columns=[ 'a', ['b', 'c'], ['b', 'c'] ], there's no check for this condition, and the creation will follow as if all items, including the lists, are valid column names.

Solution:

Added a check in the Index constructor for this case. Raise ValueError.
Added test to check if is raising correctly.
Changed a test that should raise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Index.drop_duplicates() is inconsistent for unhashable values
1 participant