INNER CODE UNIT · Python

uk_polygon

aeturrell/coding-for-economists · data_set_prep.py:85

    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")
    cv_df = cv_df.rename(columns={"areaCode": "LAD20CD", "areaName": "LAD20NM"})

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…