-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_schemas.py
More file actions
65 lines (51 loc) · 1.76 KB
/
_schemas.py
File metadata and controls
65 lines (51 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""Schemas for key files."""
from pandera.pandas import DataFrameModel, Field, check
from pandera.typing.geopandas import GeoSeries
from pandera.typing.pandas import Index, Series
class ShapeSchema(DataFrameModel):
class Config:
coerce = True
strict = "filter"
shape_id: Series[str] = Field(unique=True)
"Unique ID for this shape."
country_id: Series[str]
"ISO alpha-3 code."
shape_class: Series[str] = Field(isin=["land", "maritime"])
"Shape classifier"
geometry: GeoSeries
"Shape polygon."
index: Index[int] = Field(unique=True)
@check("geometry", element_wise=True)
def geom_not_empty(cls, geom):
return (geom is not None) and (not geom.is_empty) and geom.is_valid
class EIAGenerationSchema(DataFrameModel):
class Config:
coerce = True
strict = True
country_id: Series[str]
"Country ISO-3 code"
year: Series[int]
"Sample year"
category: Series[str] = Field(isin=["hydropower"])
generation_mwh: Series[float] = Field(ge=0)
"Hydropower generation for the given year"
index: Index[int] = Field(unique=True)
class PowerplantSchema(DataFrameModel):
class Config:
coerce = True
strict = "filter"
index: Index[int] = Field(unique=True)
powerplant_id: Series[str] = Field(unique=True)
"Unique ID for the powerplant."
output_capacity_mw: Series[float] = Field(ge=0)
"Powerplant output capacity in Megawatts."
technology: Series[str]
"Powerplant technology (e.g., run of river, basin)."
# Temporal aspects
start_year: Series[float] = Field(ge=0)
"Installation year."
end_year: Series[float] = Field(ge=0)
"Expected decommissioning year."
# Location
geometry: GeoSeries
"Powerplant point data."