Covid Data Spring 2021

Photo by AJ on Unsplash

So, with Covid declining in the UK I didn’t notice issues arising with the data.

Public Health England data team have deemed the single .csv file legacy. There used to be just one .csv file https://coronavirus.data.gov.uk/downloads/csv/coronavirus-cases_latest.csv

But now its unreliably legacy. The contents been separated out into 4 files.

LTLA: https://api.coronavirus.data.gov.uk/v2/data?areaType=ltla&metric=cumCasesBySpecimenDate&metric=newCasesBySpecimenDate&metric=cumCasesBySpecimenDateRate&format=csv

UTLA: https://api.coronavirus.data.gov.uk/v2/data?areaType=utla&metric=cumCasesBySpecimenDate&metric=newCasesBySpecimenDate&metric=cumCasesBySpecimenDateRate&format=csv

Nation: https://api.coronavirus.data.gov.uk/v2/data?areaType=nation&metric=cumCasesBySpecimenDate&metric=newCasesBySpecimenDate&metric=cumCasesBySpecimenDateRate&format=csv

Region: https://api.coronavirus.data.gov.uk/v2/data?areaType=region&metric=cumCasesBySpecimenDate&metric=newCasesBySpecimenDate&metric=cumCasesBySpecimenDateRate&format=csv

So a modified bit of code to graph your area:

#!/usr/bin/env python3
import sys
import requests
import pandas as pd
import csv
import plotly.express as px
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
url='https://api.coronavirus.data.gov.uk/v2/data?areaType=ltla&metric=cumCasesBySpecimenDate&metric=newCasesBySpecimenDate&metric=cumCasesBySpecimenDateRate&format=csv'
df = pd.read_csv(url)
df.to_csv("coronavirus-cases_latest-ltla.csv")
#df = pd.read_csv("coronavirus-cases_latest-ltla.csv")
df = df.query('(areaName == "Wokingham" ) or \
       (areaName == "Reading") or \
       (areaName == "Chorley") or \
       (areaName == "Newcastle upon Tyne") or \
       (areaName == "Dacorum") ')
df =  df.sort_values(by='date')
fig =  px.line(df, x = 'date', y = 'newCasesBySpecimenDate', title='Covid For Area of Interest',  color='areaName',\
	 hover_name = 'areaName', )
fig.show()
sys.exit()