Getting data about Coronavirus with Python in Italy

Here are the data: clike here.

The code to look at the data about coronavirus in Italy are here:

import pandas as pd



def check(what, url):
	df = pd.read_csv(url, error_bad_lines=False)
	print(what)
	print(df.loc[df["Country/Region"]=="Italy"])


check("Confirmed", "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv")

check("Recovered", "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Recovered.csv")

check("Deaths", "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Deaths.csv")

The output (at 26/02/2020) is this.

Confirmed
   Province/State Country/Region      Lat  ...  2/23/20  2/24/20  2/25/20
60            NaN          Italy  41.8719  ...      155      229      322

[1 rows x 39 columns]
Recovered
   Province/State Country/Region      Lat  ...  2/23/20  2/24/20  2/25/20
60            NaN          Italy  41.8719  ...        2        1        1

[1 rows x 39 columns]
Deaths
   Province/State Country/Region      Lat  ...  2/23/20  2/24/20  2/25/20
60            NaN          Italy  41.8719  ...        3        7       10

[1 rows x 39 columns]
>>>

More clear view of the data

import pandas as pd
from datetime import datetime


yesterday = str(datetime.today().day-1)
month = str(datetime.today().month)
print(f"{yesterday}/{month}")

def check(what, day):
	url = f"https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-{what}.csv"

	df = pd.read_csv(url, error_bad_lines=False)
	print(what, end=" ")
	result = df.loc[df["Country/Region"]=="Italy"][f"{month}/{day}/20"]
	print(list(result))

what = "Confirmed", "Recovered", "Deaths" 
for w in what:
	check(w, yesterday)

output

25/2
Confirmed [322]
Recovered [1]
Deaths [10]

 

Check the Jupyter notebook with the code for coronavirus

Check the my jupyter lab notebook with this code

 


Subscribe to the newsletter for updates
Tkinter templates
Avatar My youtube channel

Twitter: @pythonprogrammi - python_pygame

Videos

Speech recognition game

Pygame's Platform Game

Other Pygame's posts

Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.