Series Schemas

The SeriesSchema class allows for the validation of pandas Series objects, and are very similar to columns and indexes described in DataFrameSchemas.

import pandas as pd
import pandera as pa

schema = pa.SeriesSchema(
    str,
    checks=[
        pa.Check(lambda s: s.str.startswith("foo")),
        pa.Check(lambda s: s.str.endswith("bar")),
        pa.Check(lambda x: len(x) > 3, element_wise=True)
    ],
    nullable=False,
    unique=False,
    name="my_series")

validated_series = schema.validate(
    pd.Series(["foobar", "foobar", "foobar"], name="my_series")
)

validated_series
0    foobar
1    foobar
2    foobar
Name: my_series, dtype: object