1

Given this DataFrame

import pandera as pa

class MyDataframeSchema(pa.DataFrameModel):

    state: pa.Series[str] = pa.Field()
    city: pa.Series[str] = pa.Field()
    price: pa.Series[int] = pa.Field()


df = pa.DataFrame[MyDataframeSchema](
    {
        'state': ['NY','FL','GA','CA'],
        'city': ['New York', 'Miami', 'Atlanta', 'San Francisco'],
        'price': [8, 12, 10, 16],
    }
)

I'd like to be able to validate a row extracted from it

MySeriesSchema = magical_and_dreamed_method(MyDataframeSchema)

validated_series = MySeriesSchema.validate(df.iloc[0])

what would be the best way to do this?

seems wasteful to have to define the row's pa.Series by hand.

asiera
  • 492
  • 5
  • 12

0 Answers0