pandera.geopandas.GeoDataFrameModelΒΆ
- class pandera.geopandas.GeoDataFrameModel(*args, **kwargs)[source]ΒΆ
Class-based schema for
geopandas.GeoDataFramedata.Inherits
DataFrameModeland reuses the same schema-building and validation logic. Use this model whenvalidate(),example(),empty(), andstrategy()should return ageopandas.GeoDataFrame(preserving geometry columns and CRS metadata) even if the pandas backend produced a plainpandas.DataFrame.Requires the
geopandasextra. Use withpandera.typing.geopandas.GeoDataFramefor validate-on-init, e.g.GeoDataFrame[MyModel](...).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.
Methods
- classmethod build_schema_(**kwargs)[source]ΒΆ
Build a
GeoDataFrameSchemafrom the model definition.- Return type:
- classmethod empty(*_args)[source]ΒΆ
Create an empty
geopandas.GeoDataFramewith this schema.- Return type:
GeoDataFrameT[Self]
- classmethod example(cls, **kwargs)[source]ΒΆ
Generate an example of this data model specification.
- Return type:
GeoDataFrameT[Self]
- classmethod validate(check_obj, head=None, tail=None, sample=None, random_state=None, lazy=False, inplace=False)[source]ΒΆ
Validate a DataFrame based on the schema specification.
- Parameters:
check_obj (pd.DataFrame) β the dataframe to be validated.
head (int | None) β validate the first n rows. Rows overlapping with tail or sample are de-duplicated.
tail (int | None) β validate the last n rows. Rows overlapping with head or sample are de-duplicated.
sample (int | None) β validate a random sample of n rows. Rows overlapping with head or tail are de-duplicated.
random_state (int | None) β random seed for the
sampleargument.lazy (bool) β if True, lazily evaluates dataframe against all validation checks and raises a
SchemaErrors. Otherwise, raiseSchemaErroras soon as one occurs.inplace (bool) β if True, applies coercion to the object of validation, otherwise creates a copy of the data.
- Return type:
GeoDataFrameT[Self]
- Returns:
validated
DataFrame- Raises:
SchemaError β when
DataFrameviolates built-in or custom checks.