Skip to content

How to validate index using SchemaModel #905

Answered by cosmicBboy
a0th asked this question in Q&A
Discussion options

You must be logged in to vote

yep! You can use pa.typing.Index to type-annotate an index.

class Schema(pa.DataFrameModel):
    column1: pa.typing.Series[int]
    index_name: pa.typing.Index[int] = pa.Field(check_name=True)

See how you can validate a MultiIndex index: https://pandera.readthedocs.io/en/stable/dataframe_models.html#multiindex

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@joshuambg
Comment options

@cosmicBboy
Comment options

Answer selected by a0th
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants