crowsetta.formats.seq.simple.SimpleSeqSchema#
- class crowsetta.formats.seq.simple.SimpleSeqSchema(*args, **kwargs)[source]#
Bases:
DataFrameModelA
pandera.pandas.DataFrameModelthat validates apandas.DataFrameloaded from a csv or txt file in a ‘simple-seq’ format.The
SimpleSeq.from_file()loads thepandas.DataFrameand makes any changes needed to get it to this format before validation, e.g., changing column names.- __init__()#
Methods
__init__()build_schema_(**kwargs)empty(*_args)Create an empty DataFrame with the schema of this model.
example(**kwargs)Generate an example of a particular size.
Provide metadata for columns and schema level
pydantic_validate(schema_model)Verify that the input is a compatible dataframe model.
strategy(**kwargs)Create a
hypothesisstrategy for generating a DataFrame.Serialize schema metadata into json-schema format.
Create
DataFrameSchemafrom theDataFrameModel.to_yaml([stream])Convert Schema to yaml using io.to_yaml.
validate(check_obj[, head, tail, sample, ...])Validate a DataFrame based on the schema specification.
Attributes
labeloffset_sonset_s- classmethod example(**kwargs) DataFrameBase[TDataFrameModel]#
Generate an example of a particular size.
- Parameters:
size – number of elements in the generated DataFrame.
- Returns:
DataFrame object.
- classmethod pydantic_validate(schema_model: Any) DataFrameModel#
Verify that the input is a compatible dataframe model.
- classmethod strategy(**kwargs)#
Create a
hypothesisstrategy for generating a DataFrame.- Parameters:
size – number of elements to generate
n_regex_columns – number of regex columns to generate.
- Returns:
a strategy that generates DataFrame objects.
- classmethod to_json_schema()#
Serialize schema metadata into json-schema format.
- Parameters:
dataframe_schema – schema to write to json-schema format.
Note
This function is currently does not fully specify a pandera schema, and is primarily used internally to render OpenAPI docs via the FastAPI integration.
- classmethod to_schema() TSchema#
Create
DataFrameSchemafrom theDataFrameModel.
- classmethod validate(check_obj: DataFrame, head: int | None = None, tail: int | None = None, sample: int | None = None, random_state: int | None = None, lazy: bool = False, inplace: bool = False) DataFrame[Self]#
Validate a DataFrame based on the schema specification.
- Parameters:
check_obj (pd.DataFrame) – the dataframe to be validated.
head – validate the first n rows. Rows overlapping with tail or sample are de-duplicated.
tail – validate the last n rows. Rows overlapping with head or sample are de-duplicated.
sample – validate a random sample of n rows. Rows overlapping with head or tail are de-duplicated.
random_state – random seed for the
sampleargument.lazy – if True, lazily evaluates dataframe against all validation checks and raises a
SchemaErrors. Otherwise, raiseSchemaErroras soon as one occurs.inplace – if True, applies coercion to the object of validation, otherwise creates a copy of the data.
- Returns:
validated
DataFrame- Raises:
SchemaError – when
DataFrameviolates built-in or custom checks.