コード例 #1
0
ファイル: test_format.py プロジェクト: jihene-b3/covidviz
def test_format_granularity():
    df_covid_dep = cvz.choose_granularity(df_covid, "departement")
    df_covid_reg = cvz.choose_granularity(df_covid, "region")
    test_reg = cvz.format_granularity(df_covid_reg, "region")
    test_dep = cvz.format_granularity(df_covid_dep, "departement")
    assert (test_reg["maille_code"][20] == "11")
    assert (test_dep["maille_code"][5] == "16")
コード例 #2
0
ファイル: icu.py プロジェクト: jihene-b3/covidviz
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)

# %%
"""
 ICU by region
コード例 #3
0
ファイル: test_covidtime.py プロジェクト: jihene-b3/covidviz
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)
コード例 #4
0
ファイル: test_format.py プロジェクト: jihene-b3/covidviz
def test_choose_granularity():
    test1 = cvz.choose_granularity(df_covid, "departement")
    test2 = cvz.choose_granularity(df_covid, "region")
    assert list(test1.granularite.unique())[0] == "departement"
    assert list(test2.granularite.unique())[0] == "region"
コード例 #5
0
ファイル: script_gif.py プロジェクト: jihene-b3/covidviz
#%%

# import packages :
import os, sys
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + (os.path.sep + '..'))
import covidviz as cvz
import pandas as pd
import pandas_alive


#%%
# load data from covidviz 

_data = cvz.choose_columns(cvz.Load_db.save_as_df(), ['date', 'granularite', 'maille_code', 'maille_nom', 'reanimation','deces', 'cas_confirmes','gueris','source_nom'])

_data_department = cvz.choose_granularity(_data, 'departement')

_data_department = cvz.adapt_time(_data_department)

_data_region = cvz.choose_granularity(_data, 'region')
_data_region = cvz.adapt_time(_data_region)

#%%

df_clean_dep_death = cvz.data_treatment_by_option(_data_department, "deces")

cvz.plot_animation(df_clean_dep_death, "departement", "deces")


#%%
コード例 #6
0
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
data_hospitalises = gb_data['hospitalises'] + gb_data['gueris']
data_deces = gb_data['deces']
data_depcode = gb_data['maille_nom']