Example #1
0
import datetime
import sys
import os
sys.path.append(
    os.path.dirname(os.path.abspath(__file__)) + (os.path.sep + '..'))
import covidviz as cvz

# %%
"""
 ICU by department
"""

# Loading 'data_covid.csv' from covidmap

df_raw = cvz.choose_columns(cvz.Load_db.save_as_df(), [
    'date', 'granularite', 'maille_code', 'maille_nom', 'reanimation',
    'source_nom'
])

#we filtred data by department
df_dep = cvz.choose_granularity(df_raw, "departement")
# we filtred data by region
df_reg = cvz.choose_granularity(df_raw, "region")

# %%
# lineplot for all departments in different periods
cvz.icu_dep_display('since 1st confinement', df_dep)
cvz.icu_dep_display('during 1st confinement', df_dep)
cvz.icu_dep_display('during deconfinement', df_dep)
cvz.icu_dep_display('during 2nd confinement', df_dep)
cvz.icu_dep_display('during curfew', df_dep)
cvz.icu_dep_display('during 3rd confinement', df_dep)
Example #2
0
import pandas as pd
import datetime
import os.path, sys
import pandas as pd

import warnings
warnings.filterwarnings("ignore", category=RuntimeWarning)

sys.path.append(
    os.path.dirname(os.path.abspath(__file__)) + (os.path.sep + '..') * 2)
import covidviz as cvz

df_covid = pd.read_csv("covidviz/data/df_covid.csv")
df_dep = cvz.choose_granularity(df_covid, "departement")
df_covid_clean = cvz.choose_columns(df_covid, [
    'date', 'granularite', 'maille_code', 'maille_nom', 'reanimation', 'deces',
    'cas_confirmes', 'gueris', 'source_nom'
])
df_covid_clean = cvz.enable_time_series_plot(df_covid_clean,
                                             timein_field="date",
                                             timeseries_field_out="t")


def test_data_treatment():
    test = cvz.data_treatment_by_option(df_dep, "deces")
    assert (test.loc["2020-02-26", "Ain"] >= 0)


def test_adapt_time():
    test = cvz.adapt_time(df_covid)
    assert (type(test.date[1]) == pd._libs.tslibs.timestamps.Timestamp)
Example #3
0
# import packages :
import pandas as pd
import os, sys
sys.path.append(
    os.path.dirname(os.path.abspath(__file__)) + (os.path.sep + '..'))
import covidviz as cvz
from matplotlib import pyplot as plt
from IPython.display import display, Markdown
from covidviz.preprocess.clean_df import choose_columns, choose_granularity
from covidviz.covidtime.viz_epidemio import data_preparation, data_preproc, axis_date_limits, plot_field_loops, enable_time_series_plot
#from covidviz.io.load_db import Load_db

#%%
data = cvz.choose_columns(cvz.Load_db.save_as_df(), [
    'date', 'granularite', 'maille_code', 'maille_nom', 'reanimation', 'deces',
    'cas_confirmes', 'gueris', 'source_nom', 'hospitalises', 'deces_ehpad'
])
#%%
data = cvz.enable_time_series_plot(data,
                                   timein_field="date",
                                   timeseries_field_out="t")


#%%
def plots_maille_code(maille_active='FRA', **kwargs):
    fra = data_preproc(data, maille_active)
    plt.close()
    # plot_field_loops(fra, "deces_ehpad", center=False, maille_active=maille_active)
    plot_field_loops(fra,
                     "hospitalises_cumul", [7],
                     center=True,
Example #4
0
def test_choose_columns():
    test = cvz.choose_columns(df_covid, ["date", "maille_code"])
    assert list(test.columns) == ["date", "maille_code"]
Example #5
0
#%%
import matplotlib.pyplot as plt
import pandas as pd
import matplotlib.ticker as mtick

import os, sys
sys.path.append(
    os.path.dirname(os.path.abspath(__file__)) + (os.path.sep + '..'))
import covidviz as cvz
from covidviz.preprocess.clean_df import choose_columns, choose_granularity
from covidviz.covidtime.plot_covidtracker import ratio

# %%
a = cvz.Load_db.save_as_df()
data = cvz.choose_columns(a, [
    'date', 'granularite', 'maille_code', 'maille_nom', 'reanimation', 'deces',
    'cas_confirmes', 'gueris', 'hospitalises', 'source_nom'
])

# %%
data = cvz.choose_granularity(data, 'departement')

# %%
data['date'] = pd.to_datetime(data['date'])

# %%
gb_data = data[data['date'] == data['date'].max()].reset_index()
current_date = data['date'].max().strftime('%d/%m/%Y')
current_date_file = gb_data['date'].max().strftime('%d/%m/%Y')
#hospitalisees total = hospitalises + gueris
data_ratio_hospitalises = (gb_data['deces'] /
                           (gb_data['hospitalises'] + gb_data['gueris'])) * 100