COVID-19 World Survey Data API¶
This section describes how to use the COVID-19 World Survey Data API client
from Episuite. The main class used to download and parse the Facebook
Symptom survey data is the FacebookSymptomSurvey
.
See also
- COVID-19 World Symptom Survey Data API, 2020
Documentation of the API, please see Fan et al. [FLS+20] also.
- Module
episuite.mobility.facebook
Documentation of the
episuite.mobility.facebook
module.
[1]:
from matplotlib import pyplot as plt
from episuite.mobility import facebook
Available countries and regions¶
The first API we will use here is to check the countries and regions available in the dataset.
[2]:
client = facebook.FacebookSymptomSurvey()
[3]:
country_region = client.get_survey_country_region()
[4]:
country_region.head(8)
[4]:
country | region | |
---|---|---|
0 | Afghanistan | Kabul |
1 | Albania | Tiranë |
2 | Algeria | Alger |
3 | Angola | Luanda |
4 | Argentina | Buenos Aires |
5 | Argentina | Chaco |
6 | Argentina | Chubut |
7 | Argentina | Ciudad Autónoma de Buenos Aires |
[5]:
# Lets filter for some states in Brazil
brazil_regions = country_region.query("country == 'Brazil'")
[6]:
brazil_regions.tail(8)
[6]:
country | region | |
---|---|---|
72 | Brazil | Rio Grande do Norte |
73 | Brazil | Rio Grande do Sul |
74 | Brazil | Rondônia |
75 | Brazil | Roraima |
76 | Brazil | Santa Catarina |
77 | Brazil | São Paulo |
78 | Brazil | Sergipe |
79 | Brazil | Tocantins |
Survey dates available¶
The next API is to get the dates available for a region.
[7]:
result = client.get_survey_date_avail("Brazil", "Rio Grande do Sul")
[8]:
result.tail()
[8]:
country | region | survey_date | |
---|---|---|---|
326 | Brazil | Rio Grande do Sul | 20210323 |
327 | Brazil | Rio Grande do Sul | 20210324 |
328 | Brazil | Rio Grande do Sul | 20210325 |
329 | Brazil | Rio Grande do Sul | 20210326 |
330 | Brazil | Rio Grande do Sul | 20210327 |
We can see above the last available dates from the symptom survey.
Fetching survey results¶
Let’s fetch now some results from a date range.
[9]:
result = client.get_survey_range("Brazil", "Rio Grande do Sul",
"20210101", "20210318")
[10]:
result.tail()
[10]:
percent_cli | cli_se | percent_cli_unw | cli_se_unw | sample_size | country | region | iso_code | gid_0 | gid_1 | survey_date | percent_cli_95_upper_ci | percent_cli_95_lower_ci | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
72 | 0.019237 | 0.004535 | 0.019466 | 0.003710 | 1387.0 | Brazil | Rio Grande do Sul | BRA | BRA | BRA.21_1 | 2021-03-14 | 2.812560 | 1.034840 |
73 | 0.008725 | 0.003102 | 0.009072 | 0.002505 | 1433.0 | Brazil | Rio Grande do Sul | BRA | BRA | BRA.21_1 | 2021-03-15 | 1.480492 | 0.264508 |
74 | 0.020394 | 0.004812 | 0.015957 | 0.003231 | 1504.0 | Brazil | Rio Grande do Sul | BRA | BRA | BRA.21_1 | 2021-03-16 | 2.982552 | 1.096248 |
75 | 0.011194 | 0.003523 | 0.010519 | 0.002702 | 1426.0 | Brazil | Rio Grande do Sul | BRA | BRA | BRA.21_1 | 2021-03-17 | 1.809908 | 0.428892 |
76 | 0.011310 | 0.003556 | 0.012354 | 0.002894 | 1457.0 | Brazil | Rio Grande do Sul | BRA | BRA | BRA.21_1 | 2021-03-18 | 1.827976 | 0.434024 |
Visualization¶
[11]:
fig = plt.figure(figsize=(14, 4))
client.plot_region_percent_cli(result, locator="day")
plt.show()
We can see here the jump in the weighted percentage of COVID-like illness in Rio Grande do Sul/Brazil coinciding with a surge of hospitalizations that happened after February. We can also see the slow decay at the end, a good evidence of less people getting sick at home.