covizpy.plot_summary
Module Contents
Functions
|
Generate summary plot |
- covizpy.plot_summary.plot_summary(df, var='location', val='new_cases', fun='sum', date_from=None, date_to=None, top_n=5)[source]
Generate summary plot Create a horizontal bar chart summarising a specified variable and value within a time period
- Parameters
df (Pandas dataframe) – Pandas dataframe of the selected covid data from get_data()
var (str, optional) – Qualitative values to segment data. Must be a categorical variable. Also known as a ‘dimension’. By default ‘location’
val (str, optional) – Quantitative values to be aggregated. Must be numeric variable. Also known as a ‘measure’. By default ‘new_cases’
fun (str, optional) – Aggregation function for val, by default ‘sum’
date_from (str, optional) – Start date of the data range with format ‘YYYY-MM-DD’. By default ‘None’ is used to represent 7 days prior to today’s date
date_to (str, optional) – End date of data range with format ‘YYYY-MM-DD’. By default ‘None’ is used to represent today’s date
top_n (int, optional) – Specify number of qualitative values to show, by default 5
- Returns
Altair bar plot for the specified variables and period
- Return type
altair.Chart
Example
>>> plot_summary(df, var="location", var="new_cases", fun="sum", date_from="2022-01-01", date_to="2022-01-15", top_n=10)