<jupyter_start><jupyter_text>CREAZIONE SERIE STORICHE DECESSI TOTALI DELLE NAZIONI EUROPEE<jupyter_code>import pandas as pd
from datetime import datetime
from datetime import timedelta
import matplotlib.pyplot as plt

df = pd.read_csv('csv/decessi_eu_week.csv')
df.head(10)
df.drop(['SEX', 'UNIT'], axis=1, inplace=True)
df.head()
df['Value'] = df['Value'].str.replace(',', '')
df.replace({":": 0}, inplace=True)
df.head()<jupyter_output><empty_output><jupyter_text>Modifica formato del campo TIME e Value<jupyter_code>df['TIME'] = pd.to_datetime(df['TIME'] + '-1', format='%YW%W-%w')
df['Value'] = pd.to_numeric(df['Value'])
df.head()
#numero di record
index = df.index
record = len(index)
print(record)
import numpy as np
deceduti = df['Value']
print('mean', np.mean(deceduti))
print('min', np.min(deceduti))
print('max', np.max(deceduti))
df.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
RangeIndex: 21016 entries, 0 to 21015
Data columns (total 3 columns):
 #   Column  Non-Null Count  Dtype         
---  ------  --------------  -----         
 0   TIME    21016 non-null  datetime64[ns]
 1   GEO     21016 non-null  object        
 2   Value   21016 non-null  int64         
dtypes: datetime64[ns](1), int64(1), object(1)
memory usage: 492.7+ KB<jupyter_text>Creazione delle serie storiche settimanali dei decessi totali avvenuti nelle nazioni europee da gennaio 2015 ad settembre 2020 compreso  FRANCIA<jupyter_code>df_fr = df[df['GEO'] == 'France']
df_fr.head()
df_fr = df_fr[df_fr['TIME'] > '2014-12-31']
df_fr = df_fr[df_fr['TIME'] < '2020-10-01']
df_fr.head()
df_fr = df_fr.set_index('TIME')
df_fr.head()
ts_fr = df_fr.Value
ts_fr
df_fr.to_csv('csv/nazioni/serie_storica_fr.csv')
start_date = datetime(2015,1,1)
end_date = datetime(2020,9,30)
lim_ts = ts_fr[start_date:end_date]

plt.figure(figsize=(12,6))
plt.title('Decessi settimanali Francia', size=26)
plt.plot(lim_ts)
for year in range(start_date.year,end_date.year+2):
    plt.axvline(pd.to_datetime(str(year)+'-01-01'), color='k', linestyle='--', alpha=0.5)<jupyter_output><empty_output><jupyter_text>BELGIO<jupyter_code>df_be = df[df['GEO'] == 'Belgium']
df_be.head()
df_be = df_be[df_be['TIME'] > '2014-12-31']
df_be = df_be[df_be['TIME'] < '2020-10-01']
df_be.head()
df_be = df_be.set_index('TIME')
df_be.head()
ts_be = df_be.Value
ts_be
df_be.to_csv('csv/nazioni/serie_storica_be.csv')
start_date = datetime(2015,1,1)
end_date = datetime(2020,9,30)
lim_ts = ts_be[start_date:end_date]

plt.figure(figsize=(12,6))
plt.title('Decessi settimanali Belgio', size=26)
plt.plot(lim_ts)
for year in range(start_date.year,end_date.year+2):
    plt.axvline(pd.to_datetime(str(year)+'-01-01'), color='k', linestyle='--', alpha=0.5)<jupyter_output><empty_output><jupyter_text>GERMANIA<jupyter_code>df_ge = df[df['GEO'] == 'Germany (until 1990 former territory of the FRG)']
df_ge.replace({"Germany (until 1990 former territory of the FRG)": 'Germany'}, inplace=True)
df_ge.head()
df_ge = df_ge[df_ge['TIME'] > '2016-01-10']
df_ge = df_ge[df_ge['TIME'] < '2020-10-01']
df_ge.head()
df_ge=df_ge.set_index('TIME')
df_ge.head()
ts_ge = df_ge.Value
ts_ge
df_ge.to_csv('csv/nazioni/serie_storica_ge.csv')
start_date = datetime(2016,1,1)
end_date = datetime(2020,9,30)
lim_ts = ts_ge[start_date:end_date]

plt.figure(figsize=(12,6))
plt.title('Decessi settimanali Germania', size=26)
plt.plot(lim_ts)
for year in range(start_date.year,end_date.year+2):
    plt.axvline(pd.to_datetime(str(year)+'-01-01'), color='k', linestyle='--', alpha=0.5)<jupyter_output><empty_output><jupyter_text>SPAGNA<jupyter_code>df_sp = df[df['GEO'] == 'Spain']
df_sp.head()
df_sp = df_sp[df_sp['TIME'] > '2014-12-31']
df_sp = df_sp[df_sp['TIME'] < '2020-10-01']
df_sp.head()
df_sp = df_sp.set_index('TIME')
df_sp.head()
ts_sp = df_sp.Value
ts_sp
df_sp.to_csv('csv/nazioni/serie_storica_sp.csv')
start_date = datetime(2015,1,1)
end_date = datetime(2020,9,30)
lim_ts = ts_sp[start_date:end_date]

plt.figure(figsize=(12,6))
plt.title('Decessi settimanali Spagna', size=26)
plt.plot(lim_ts)
for year in range(start_date.year,end_date.year+2):
    plt.axvline(pd.to_datetime(str(year)+'-01-01'), color='k', linestyle='--', alpha=0.5)<jupyter_output><empty_output><jupyter_text>REGNO UNITO<jupyter_code>df_uk = df[df['GEO'] == 'United Kingdom']
df_uk.head()
df_uk = df_uk[df_uk['TIME'] > '2015-01-04']
df_uk = df_uk[df_uk['TIME'] < '2020-10-01']
df_uk.head()
df_uk=df_uk.set_index('TIME')
df_uk.head()
ts_uk = df_uk.Value
ts_uk
df_uk.to_csv('csv/nazioni/serie_storica_uk.csv')
start_date = datetime(2015,1,1)
end_date = datetime(2020,9,30)
lim_ts = ts_uk[start_date:end_date]

plt.figure(figsize=(12,6))
plt.title('Decessi settimanali Regno Unito', size=26)
plt.plot(lim_ts)
for year in range(start_date.year,end_date.year+2):
    plt.axvline(pd.to_datetime(str(year)+'-01-01'), color='k', linestyle='--', alpha=0.5)<jupyter_output><empty_output><jupyter_text>PORTOGALLO<jupyter_code>df_pt = df[df['GEO'] == 'Portugal']
df_pt.head()
df_pt = df_pt[df_pt['TIME'] > '2015-01-01']
df_pt = df_pt[df_pt['TIME'] < '2020-10-01']
df_pt.head()
df_pt = df_pt.set_index('TIME')
df_pt.head()
ts_pt = df_pt.Value
ts_pt
df_pt.to_csv('csv/nazioni/serie_storica_pt.csv')
start_date = datetime(2015,1,1)
end_date = datetime(2020,9,30)
lim_ts = ts_pt[start_date:end_date]

plt.figure(figsize=(12,6))
plt.title('Decessi settimanali Portogallo', size=26)
plt.plot(lim_ts)
for year in range(start_date.year,end_date.year+2):
    plt.axvline(pd.to_datetime(str(year)+'-01-01'), color='k', linestyle='--', alpha=0.5)<jupyter_output><empty_output><jupyter_text>GRECIA<jupyter_code>df_gr = df[df['GEO'] == 'Greece']
df_gr.head()
df_gr = df_gr[df_gr['TIME'] > '2015-01-04']
df_gr = df_gr[df_gr['TIME'] < '2020-09-01']
df_gr.head()
df_gr = df_gr.set_index('TIME')
df_gr.head()
ts_gr = df_gr.Value
ts_gr
df_gr.to_csv('csv/nazioni/serie_storica_gr.csv')
start_date = datetime(2015,1,1)
end_date = datetime(2020,8,31)
lim_ts = ts_gr[start_date:end_date]

plt.figure(figsize=(12,6))
plt.title('Decessi settimanali Grecia', size=26)
plt.plot(lim_ts)
for year in range(start_date.year,end_date.year+2):
    plt.axvline(pd.to_datetime(str(year)+'-01-01'), color='k', linestyle='--', alpha=0.5)<jupyter_output><empty_output><jupyter_text>ROMANIA<jupyter_code>df_ro = df[df['GEO'] == 'Romania']
df_ro.head()
df_ro = df_ro[df_ro['TIME'] > '2015-01-04']
df_ro = df_ro[df_ro['TIME'] < '2020-10-01']
df_ro.head()
df_ro = df_ro.set_index('TIME')
df_ro.head()
ts_ro = df_ro.Value
ts_ro
df_ro.to_csv('csv/nazioni/serie_storica_ro.csv')
start_date = datetime(2015,1,1)
end_date = datetime(2020,9,30)
lim_ts = ts_ro[start_date:end_date]

plt.figure(figsize=(12,6))
plt.title('Decessi settimanali Romania', size=26)
plt.plot(lim_ts)
for year in range(start_date.year,end_date.year+2):
    plt.axvline(pd.to_datetime(str(year)+'-01-01'), color='k', linestyle='--', alpha=0.5)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1870107277471731, 'fraction_numerical': 0.05711800521890403, 'mean_word_length': 6.614790286975717, 'pattern_counts': {'":': 3, '<': 49, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '239714', 'license': 'Unlicense', 'n_tokens_mistral': 3268, 'n_tokens_neox': 3011, 'n_words': 442, 'path': 'Modulo 5 - Analisi europea/Creazione decessi totali nazioni europa.ipynb', 'repo_name': 'SofiaBlack/Towards-a-software-to-measure-the-impact-of-the-COVID-19-outbreak-on-Italian-deaths', 'size': '6898'}