Example usage

Here we will demonstrate how to use bccovideda to show the summary stats and to plot the line plot and histogram of Covid19 cases in BC

Imports

from bccovideda.get_data import get_data
from bccovideda.show_summary_stat import show_summary_stat
from bccovideda.plot_line_by_date import plot_line_by_date
from bccovideda.plot_hist_by_cond import plot_hist_by_cond
import altair as alt
alt.renderers.enable("html")
from altair import pipe, limit_rows, to_values
t = lambda data: pipe(data, limit_rows(max_rows=1000000), to_values)
alt.data_transformers.register('custom', t)
alt.data_transformers.enable('custom')
DataTransformerRegistry.enable('custom')

Get Covid19 data in BC

get_data() downloads Covid19 data from a summary statistics from BCCDC and returns a dataframe

get_data()
Reported_Date HA Sex Age_Group Classification_Reported
0 2020-01-29 Out of Canada M 40-49 Lab-diagnosed
1 2020-02-06 Vancouver Coastal F 50-59 Lab-diagnosed
2 2020-02-10 Out of Canada F 20-29 Lab-diagnosed
3 2020-02-10 Out of Canada M 30-39 Lab-diagnosed
4 2020-02-18 Interior F 30-39 Lab-diagnosed
... ... ... ... ... ...
320535 2022-01-27 Interior F 40-49 Lab-diagnosed
320536 2022-01-27 Fraser F 30-39 Lab-diagnosed
320537 2022-01-27 Vancouver Coastal F 70-79 Lab-diagnosed
320538 2022-01-27 Interior M 80-89 Lab-diagnosed
320539 2022-01-27 Interior F 60-69 Lab-diagnosed

320540 rows × 5 columns

Show summary statistics

show_summary_stat(startDate, endDate) can show a summary statistics of Covid19 cases in BC during the period specified by startDate and endDate.

show_summary_stat("2021-01-01", "2021-01-30").T
0
total_cases_count 14678
latest_date 2021-01-06 00:00:00
latest_daily_cases_count 607
max_date 2021-01-06 00:00:00
max_daily_cases_count 607
min_date 2021-01-17 00:00:00
min_daily_cases_count 320
max_age_group 20-29
max_age_group_count 3556
min_age_group 90+
min_age_group_count 228
max_region Fraser
max_region_count 6976
min_region Out of Canada
min_region_count 23

Plots a line chart

plot_line_by_date(startDate, endDate) plots a line chart of regional Covid19 cases over the period specified by startDate and endDate.

plot_line_by_date("2021-01-01", "2021-01-30")

Plots a histogram

plot_hist_by_cond(startDate, endDate, condition) plots a histogram of regional Covid19 cases over the period specified by startDate and endDate. “Age” or “Region” can be used as condition argument.

plot_hist_by_cond("2021-01-01", "2021-01-30", "Age")