INNER CODE UNIT · Python
uk_bound_box
aeturrell/coding-for-economists · data_set_prep.py:84
uk_bound_box = (-7.57216793459, 49.959999905, 1.68153079591, 58.6350001085)
uk_polygon = shapely.geometry.box(*uk_bound_box, ccw=True)
rivers = rivers[rivers.within(uk_polygon)]
rivers.to_file(os.path.join("data", "geo", "rivers", "rivers.shp"))
def prep_covid_data():
"""
Downloads covid data from uk gov't website and processes it ready for plotting.
"""
# data_url = "https://api.coronavirus.data.gov.uk/v2/data?areaType=ltla&metric=newDeaths28DaysByDeathDate&format=csv&release=2021-02-27"
cv_df = pd.read_csv(os.path.join("~", "Downloads", "ltla_2021-02-27.csv"))
cv_df["date"] = pd.to_datetime(cv_df["date"])
cv_df["newDeaths28DaysByDeathDate"] = cv_df["newDeaths28DaysByDeathDate"].astype(
int
)
cv_df["areaCode"] = cv_df["areaCode"].astype("string")
cv_df["areaName"] = cv_df["areaName"].astype("string")