Plotting Covid Data in Python

Okay, everyone is at it. How hard can it be.

#!/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
df = pd.read_csv("https://coronavirus.data.gov.uk/downloads/csv/coronavirus-cases_latest.csv")
df.to_csv("coronavirus-cases_latest.csv")
#df = pd.read_csv("coronavirus-cases_latest.csv")
df = df.query('(`Area name` == "Wokingham" ) or \
       (`Area name` == "Reading") or \
       (`Area name` == "Chorley") or \
       (`Area name` == "Newcastle upon Tyne") or \
       (`Area name` == "Dacorum") ')
df =  df.sort_values(by='Specimen date')
fig =  px.line(df, x = 'Specimen date', y = 'Daily lab-confirmed cases', title='Covid For Area of Interest',  color='Area name',\
	 hover_name = 'Area name', )
fig.show()
sys.exit()

""" 
Compatibility/pip info:
python3.8 -m pip install requests
certifi==2020.12.5
chardet==4.0.0
idna==2.10
pkg-resources==0.0.0
requests==2.25.1
urllib3==1.26.3
"""

Leave a Reply

Your email address will not be published. Required fields are marked *