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

reset_index() not functioning properly with more than two indexes #1790

Open
2 of 3 tasks
roumenv opened this issue Aug 27, 2024 · 0 comments
Open
2 of 3 tasks

reset_index() not functioning properly with more than two indexes #1790

roumenv opened this issue Aug 27, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@roumenv
Copy link

roumenv commented Aug 27, 2024

Describe the bug
When a pandera DataFrameSchema has an index with more than two levels, the reset_index method does not appear to work as expected. For example, the ability to drop a particular index using the method results in no index change.

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of pandera.
  • (optional) I have confirmed this bug exists on the main branch of pandera.

Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

import pandera as pa
example_schema = pa.DataFrameSchema({
    "category" : pa.Column(str)},
    index = pa.MultiIndex([
        pa.Index(name="unique_id1", dtype=int),
        pa.Index(name="unique_id2", dtype=str),
        pa.Index(name="unique_id3", dtype=float)
        ]
    )
)

print(example_schema.reset_index(level = ["unique_id1"], drop=True).index)

Expected behavior

In the example above, I would expected the modified schema to have an index with two levels unique_id2 and unique_id3 as it does when we try to drop an index level from a index with two levels.

Desktop (please complete the following information):

  • OS: macOS Sonoma 14.6.1
  • Version: pandera 20.2

Screenshots

Screenshot 2024-08-27 at 1 13 46 PM

Additional context

@roumenv roumenv added the bug Something isn't working label Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant