crowsetta.formats.bbox.raven.RavenSchema#

class crowsetta.formats.bbox.raven.RavenSchema(*args, **kwargs)[source]#

Bases: DataFrameModel

A pandera.pandas.DataFrameModel that validates a pandas.DataFrame loaded from a txt file, created by exporting a Selection Table from Raven.

__init__()#

Methods

__init__()

build_schema_(**kwargs)

empty(*_args)

Create an empty DataFrame with the schema of this model.

example(**kwargs)

Generate an example of this data model specification.

from_json(source)

Load a schema from JSON.

from_yaml(yaml_schema)

Load a schema from YAML.

get_metadata()

Provide metadata for columns and schema level

pydantic_validate(schema_model)

Verify that the input is a compatible dataframe model.

strategy(**kwargs)

Create a data synthesis strategy.

to_json([target])

Convert this model's schema to JSON.

to_json_schema()

Serialize schema metadata into json-schema format.

to_schema()

Create DataFrameSchema from the DataFrameModel.

to_yaml([stream])

Convert this model's schema to YAML.

validate(check_obj[, head, tail, sample, ...])

Validate a DataFrame based on the schema specification.

Attributes

annotation

begin_time_s

end_time_s

high_freq_hz

low_freq_hz

class Config[source]#

Bases: object

classmethod empty(*_args) → DataFrame[Self]#

Create an empty DataFrame with the schema of this model.

classmethod example(**kwargs) → DataFrameBase[Self]#

Generate an example of this data model specification.

classmethod from_json(source)#

Load a schema from JSON.

Parameters:

source – str, Path, or file stream with JSON content.

Returns:

the backend-specific schema object.

classmethod from_yaml(yaml_schema)#

Load a schema from YAML.

Parameters:

yaml_schema – str, Path, or file stream with YAML content.

Returns:

the backend-specific schema object.

classmethod get_metadata() → dict[Any, Any]#

Provide metadata for columns and schema level

classmethod pydantic_validate(schema_model: Any) → DataFrameModel#

Verify that the input is a compatible dataframe model.

classmethod strategy(**kwargs)#

Create a data synthesis strategy.

classmethod to_json(target: PathLike | None = None, **kwargs)#

Convert this model’s schema to JSON.

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 DataFrameSchema from the DataFrameModel.

classmethod to_yaml(stream: PathLike | None = None)#

Convert this model’s schema to YAML.

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 sample argument.

  • lazy – if True, lazily evaluates dataframe against all validation checks and raises a SchemaErrors. Otherwise, raise SchemaError as 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 DataFrame violates built-in or custom checks.