|
1 | 1 | """Schemas for tabular data used in the workflow.""" |
2 | 2 |
|
3 | | -from pandera.pandas import DataFrameModel, Field, check |
| 3 | +import pandera.pandas as pa |
4 | 4 | from pandera.typing.geopandas import GeoSeries |
5 | 5 | from pandera.typing.pandas import Series |
6 | | -from shapely.geometry import Point |
7 | 6 |
|
8 | 7 |
|
9 | | -class Shapes(DataFrameModel): |
10 | | - class Config: |
11 | | - coerce = True |
12 | | - strict = False |
| 8 | +class ShapesSchema(pa.DataFrameModel): |
| 9 | + """Schema for geographic shapes.""" |
13 | 10 |
|
14 | | - shape_id: Series[str] = Field(unique=True) |
15 | | - "Unique ID for this shape." |
| 11 | + shape_id: Series[str] = pa.Field(unique=True) |
| 12 | + "A unique identifier for this shape." |
16 | 13 | country_id: Series[str] |
17 | | - "ISO alpha-3 code." |
18 | | - shape_class: Series[str] = Field(isin=["land", "maritime"]) |
19 | | - "Shape classifier" |
20 | | - geometry: GeoSeries[Point] = Field() |
21 | | - "Shape polygon." |
| 14 | + "Country ISO alpha-3 code." |
| 15 | + shape_class: Series[str] = pa.Field(isin=["land", "maritime"]) |
| 16 | + "Identifier of the shape's context." |
| 17 | + geometry: GeoSeries |
| 18 | + "Shape (multi)polygon." |
| 19 | + parent_name: Series[str] | None |
| 20 | + "Human-readable name in the parent dataset." |
22 | 21 |
|
23 | | - @check("geometry", element_wise=True) |
24 | | - def geom_not_empty(cls, geom): |
| 22 | + @pa.check("geometry", element_wise=True) |
| 23 | + def check_geometries(cls, geom): |
25 | 24 | return (geom is not None) and (not geom.is_empty) and geom.is_valid |
| 25 | + |
| 26 | + class Config: |
| 27 | + coerce = True |
| 28 | + strict = False |
0 commit comments