unionai-oss / pandera

A light-weight, flexible, and expressive statistical data testing library
https://www.union.ai/pandera
MIT License
3.37k stars 310 forks source link

Multiindex unique does not get passed in Schema model #869

Open mattB1989 opened 2 years ago

mattB1989 commented 2 years ago

Describe the bug A clear and concise description of what the bug is.

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
from pandera.typing import Index, Series

class MultiIndexSchema(pa.SchemaModel):

    year: Index[int] = pa.Field(gt=2000, coerce=True)
    month: Index[int] = pa.Field(ge=1, le=12, coerce=True)
    passengers: Series[int]

    class Config:
        # provide multi index options in the config
        multiindex_name = "time"
        multiindex_strict = True
        multiindex_coerce = True
        multiindex_unique = True

index = MultiIndexSchema.to_schema().index

Expected behavior

I would expect SchemaModel and schema objects to have the same functionality, including for validation of multi index, including all the flags passed to the MultIndex class.

Desktop (please complete the following information):

Additional context

Ideally there should be a test that the features are the same. I'm happy to fix this bug (as it is a simple one-liner), but there probably should be more reflection on how to make sure that the features don't diverge between the 2 syntax. I will try to submit a PR, this is a great project, I hope I will be able to contribute in the future.

mattB1989 commented 2 years ago

Here is the PR: https://github.com/pandera-dev/pandera/pull/870