Exemple #1
0
def run(report, date_ini, date_end, points_betw_days, country_list):
    title = "SOC plot for all countries. Date from {} to {}".format(
        date_ini, date_end)
    report.add_paragraph(title)
    country_objs = [
        getdata.CovidData(country=country,
                          date_ini=date_ini,
                          date_end=date_end,
                          do_dropna=False,
                          start_after_new_cases=0,
                          acquire_tests=True) for country in country_list
    ]
    run_plot_and_soc(country_objs, points_betw_days, report)
Exemple #2
0
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 17 17:51:03 2020

@author: Giovanni Guarnieri Soares
"""

import matplotlib.pyplot as plt

from tools import imcsf_covid_19, getdata, createdocument


def run(country_objs, doc):
    for obj in country_objs:
        imcsf_covid_19.make_predict(obj.df["new_cases"].to_list(),
                                    obj.location,
                                    savegraphs=False,
                                    doc=doc)


if __name__ == '__main__':
    countries = ["Brazil", "Italy"]
    obj_list = [getdata.CovidData(country=country) for country in countries]
    report = createdocument.ReportDocument()
    run(obj_list, report)
    report.finish()
    plt.show()
# Local imports:
from tools import getdata, createdocument, cullen_frey_giovanni


def run(country_objs, report):
    report.add_heading("Cullen-Frey charts for each time series", level=3)
    location_list = [data.location for data in country_objs]
    for var in country_objs[0].df.columns:
        if var not in ['date', 'index']:
            report.add_heading("Cullen-Frey for " + var, level=4)
            skews = list()
            kurt = list()
            for obj in country_objs:
                var_list = obj.df[var].to_list()
                skews.append(skew(var_list))
                kurt.append(kurtosis(var_list, fisher=False))

            cullen_frey_giovanni.cullenfrey(skews, kurt, location_list,
                                            var.replace("_", " ").title())
            report.add_fig()


if __name__ == "__main__":
    doc = createdocument.ReportDocument()
    objs_list = [
        getdata.CovidData(country=country) for country in ["Brazil", "Italy"]
    ]
    run(objs_list, doc)
    plt.show()

def run(country_objs, report):
    report.add_heading("Item 1", level=2)
    report.add_heading("Time Series Plots", level=3)
    report.add_paragraph("Here we plot the time series charts for the variables under investigation.")
    for var in country_objs[0].df.columns:
        if var not in ['date', 'index']:
            report.add_heading("Plot for " + var, level=4)
            ax = None
            for obj in country_objs:
                if ax is None:
                    ax = obj.df.plot(x='date', y=var, label=obj.location)
                else:
                    obj.df.plot(x='date', y=var, label=obj.location, ax=ax)
            plt.grid('both')
            plt.legend(loc='center left', bbox_to_anchor=(1, 0.5))
            plt.title('Time series of ' + var.replace("_", " ").title() + ' for selected locations')
            plt.tight_layout()
            plt.draw()
            report.add_fig()


if __name__ == "__main__":
    doc = createdocument.ReportDocument()
    objs_list = [getdata.CovidData(country=country) for country in ["Brazil", "Italy", "China"]]
    objs_list += [getdata.CovidData()]
    run(objs_list, doc)
    plt.show()