I am learning pandas and matplotlib on my own by using some public dataset via
this api link
I'm using colab and below are my codes:
import datetime
import io
import json
import pandas as pd
import requests
import matplotlib.pyplot as plt
confirm_resp = requests.get('https://api.data.gov.hk/v2/filterq=%7B%22resource%22%3A%22http%3A%2F%2Fwww.chp.gov.hk%2Ffiles%2Fmisc%2Fenhanced_sur_covid_19_eng.csv%22%2 C%22section%22%3A1%2C%22format%22%3A%22json%22%7D').content
confirm_df = pd.read_json(io.StringIO(confirm_resp.decode('utf-8')))
confirm_df.columns = confirm_df.columns.str.replace(" ", "_")
pd.to_datetime(confirm_df['Report_date'])
confirm_df.columns = ['Case_no', 'Report_date', 'Onset_date', 'Gender', 'Age',
'Name_of_hospital_admitted', 'Status', 'Resident', 'Case_classification', 'Confirmed_probable']
confirm_df = confirm_df.drop('Name_of_hospital_admitted', axis = 1)
confirm_df.head()
and this is what the dataframe looks like:
Case_no |
Report_date |
Onset_date |
Gender |
Age |
Status |
Resident |
Case_classification |
Confirmed_probable |
1 |
23/01/2020 |
21/01/2020 |
M |
39 |
Discharged |
Non-HK resident |
Imported case |
Confirmed |
2 |
23/01/2020 |
18/01/2020 |
M |
56 |
Discharged |
HK resident |
Imported case |
Confirmed |
3 |
24/01/2020 |
20/01/2020 |
F |
62 |
Discharged |
Non-HK resident |
Imported case |
Confirmed |
4 |
24/01/2020 |
23/01/2020 |
F |
62 |
Discharged |
Non-HK resident |
Imported case |
Confirmed |
5 |
24/01/2020 |
23/01/2020 |
M |
63 |
Discharged |
Non-HK resident |
Imported case |
Confirmed |
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…