<jupyter_start><jupyter_text>Results for analisys of COVID data of Mexico at 2021/04/23 Import libraries<jupyter_code>import os
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from IPython.display import Markdown as md
%matplotlib inline<jupyter_output><empty_output><jupyter_text>Importing dataset into panda dataframes<jupyter_code>df_national = pd.read_csv('./data/filter_nat.csv')
df_dictionary_states = pd.read_excel('./data/diccionario_datos_covid19/201128 Catalogos.xlsx',
                                    sheet_name='Catálogo de ENTIDADES',
                                    index_col='CLAVE_ENTIDAD')
df_dictionary_clasification = pd.read_excel('./data/diccionario_datos_covid19/201128 Catalogos.xlsx',
                                    sheet_name='Catálogo CLASIFICACION_FINAL',
                                    index_col='CLAVE', 
                                    skiprows=2)<jupyter_output><empty_output><jupyter_text>The dictionary contains the list of states, that will be used to fill our plots with information.<jupyter_code>df_dictionary_states.head()
states_code = df_dictionary_states.loc[:32,"ABREVIATURA"]
states_code.head()<jupyter_output><empty_output><jupyter_text>Clasification dictionary<jupyter_code>df_dictionary_clasification.head(n=7)<jupyter_output><empty_output><jupyter_text>Filter positives cases indentified when **CLASIFICACION_FINAL** is 1,2 or 3. When **FECHA_DEF** is diferent to `999-999-99` is considered as a death case. We added the **DEATH** column in the positive dataset.<jupyter_code>positives =  df_national.loc[df_national["CLASIFICACION_FINAL"] < 4,:]
# mask_alive = positives.loc[:,"FECHA_DEF"].str.contains('9999-99-99', na = False)
positives = positives.assign(DEATH=np.ones(positives.shape[0], dtype = np.int32))
positives.loc[positives["FECHA_DEF"]=='9999-99-99',"DEATH"] = 0
positives.head()<jupyter_output><empty_output><jupyter_text>Create a State category from State dictionary<jupyter_code>positives["state"] = positives["ENTIDAD_RES"].astype("category")
positives["state"].cat.categories = states_code.iloc[:]<jupyter_output><empty_output><jupyter_text>Rollup data by state<jupyter_code>state_aggregate = positives[["state","DEATH"]].groupby("state").agg(['count', 'sum'])
positive_mean, death_mean = state_aggregate.mean()[0:2]
plt.plot(states_code, state_aggregate[('DEATH', 'count')], label="Positive")
plt.plot(states_code, state_aggregate[('DEATH', 'sum')], label="Deaths")
plt.title("COVID-19 Cases by State")
plt.xlabel('States')
plt.ylabel('Number of Cases')
plt.legend()
plt.show()<jupyter_output><empty_output><jupyter_text>Stats<jupyter_code>md("""# National stats
**Positive COVID19 mean:** {0:,.0f}

**Death by COVID19 mean:** {1:,.0f}
""".format(positive_mean, death_mean)
)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1321492007104796, 'fraction_numerical': 0.02557726465364121, 'mean_word_length': 5.610328638497653, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '542319', 'license': 'MIT', 'n_tokens_mistral': 1048, 'n_tokens_neox': 943, 'n_words': 164, 'path': 'work/results.ipynb', 'repo_name': 'luisjba/docker-mcd-covid19-mx', 'size': '2815'}