Schemas

Return to Homepage

DataFrame Schemas with Pandera.

class gval.utils.schemas.AttributeTrackingDf(*args, **kwargs)

Defines the schema for output of _attribute_tracking_xarray() The attributes could be of any datatype. For instance, if your attributes are of float type, you can use Series[float] instead of Series[object].

class Config
coerce = True
name = 'AttributeTrackingDf'
strict = False
attribute_1_benchmark: Series[object] | None = 'attribute_1_benchmark'
attribute_1_candidate: Series[object] | None = 'attribute_1_candidate'
attribute_2_benchmark: Series[object] | None = 'attribute_2_benchmark'
attribute_2_candidate: Series[object] | None = 'attribute_2_candidate'
classmethod validate_column_suffixes(df: DataFrame, candidate_suffix: str, benchmark_suffix: str) Series[bool]

Checks that each column name in the dataframe ends with either ‘_candidate’ or ‘_benchmark’.

class gval.utils.schemas.Conditions_df(*args, **kwargs)

Cateogrical conditions df

Inherits columns from Sample_identifiers

class Config
coerce = True
name = 'Conditions_df'
ordered = False
fn: Series[float] | None = 'fn'
fp: Series[float] | None = 'fp'
tn: Series[float] | None = 'tn'
tp: Series[float] | None = 'tp'
class gval.utils.schemas.Crosstab_df(*args, **kwargs)

Crosstab DF schema

Inherits columns from Sample_identifiers

class Config
coerce = True
name = 'Crosstab_df'
strict = True
agreement_values: Series[float] | None = 'agreement_values'
benchmark_values: Series = 'benchmark_values'
candidate_values: Series = 'candidate_values'
counts: Series[float] = 'counts'
class gval.utils.schemas.Metrics_df(*args, **kwargs)

Metrics DF schema

Inherits columns from Conditions_df

class Config
coerce = True
name = 'Metrics_df'
strict = False
class gval.utils.schemas.Pivoted_crosstab_df(*args, **kwargs)

Pivoted Crosstab DF schema

class Config
coerce = True
name = 'Pivoted_crosstab_df'
strict = True
col_idx: Series[str] = 'col_idx'
classmethod column_index_name(df: DataFrame) Series[bool]

Checks that column index name is ‘benchmark_values’

row_idx: Index[Int64] = <Schema Index(name=candidate_values, type=None)>
class gval.utils.schemas.Prob_metrics_df(*args, **kwargs)

Probabilistic metrics DF schema

class Config
coerce = False
name = 'Prob_metrics_df'
strict = False
metrics: Series[object] | None = 'metrics'
class gval.utils.schemas.Sample_identifiers(*args, **kwargs)

Crosstab DF schema

class Config
coerce = True
name = 'Sample_identifiers'
strict = True
band: Series[str] = 'band'
idx: Index[Int64] = 'idx'
class gval.utils.schemas.Subsample_identifiers(*args, **kwargs)

Crosstab DF schema

class Config
coerce = True
name = 'Subsample_identifiers'
strict = True
idx: Index[Int64] = 'idx'
subsample: Series[str] | None = 'subsample'
class gval.utils.schemas.SubsamplingDf(*args, **kwargs)

Defines the schema for subsampling DataFrame`

class Config
coerce = True
name = 'SubsamplingDf'
strict = False
geometry: Series[Geometry] = 'geometry'
subsample_id: Series[int] = 'subsample_id'
subsample_type: Series[str] = 'subsample_type'
weights: int | float | None = 'weights'
class gval.utils.schemas.Xrspatial_crosstab_df(*args, **kwargs)

Defines the schema for output of xrspatial.zonal.crosstab()

class Config
coerce = True
name = 'Xrspatial_crosstab_df'
strict = False
zone: Series[float] = 'zone'
class gval.utils.schemas.columns_method(*args, **kwargs)

Defines base data frame model with columns method

class Config
name: str | None = 'columns_method'

name of schema

classmethod columns() List[str]

Gives access to columns from DataFrameModel