<jupyter_start><jupyter_text>Correlation analyzes of case/death rate with multiple variables in municipality level (admin2)This Notebook read the collection of variables at state level collected in this week ([variables](Week3_variables_municipalities.ipynb), [population density](Week3_population_density_states.ipynb) and [comorbidities](Week3_comorbidities.ipynb)) and shows the correlation between those variables and the case/death rate through specific areas viewpoints.<jupyter_code>import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from string import ascii_letters
import numpy as np

%matplotlib inline
%reload_ext autoreload
%autoreload 2<jupyter_output><empty_output><jupyter_text>The collection of variables is read<jupyter_code>dfVar=pd.read_csv('../data/week3_variables_municipalities.csv')
dfPopDens=pd.read_csv('../data/week3_population_density_municipalities.csv')
dfComorbidities=pd.read_csv('../data/week3_comorbidities_municipalities.csv')
dfVar.head()
dfPopDens.head()
dfComorbidities.head()<jupyter_output><empty_output><jupyter_text>All the variables are merged into one dataframe<jupyter_code>dfAll = pd.merge(dfVar,dfPopDens,on=['cve_ent'])
dfAll = pd.merge(dfAll,dfComorbidities,on=['cve_ent'])<jupyter_output><empty_output><jupyter_text>Heatmap of health variables correlation with case/death rate  All the variables related to health and the case/death rate are selected<jupyter_code>dfHealth = dfAll[['case_rate', 'case_rate_last_60_days',
       'death_rate', 'death_rate_last_60_days',
       'pct_disability', 'pct_limitation', 'pct_mental_problem',
       'pct_no_problems', 'pct_pop_obesity', 'pct_pop_hypertension',
       'pct_pop_diabetes']].copy()<jupyter_output><empty_output><jupyter_text>The correlation between the health and the case/death rate is as following<jupyter_code>corr = dfHealth.corr()
mask = np.triu(np.ones_like(corr, dtype=bool))
f, ax = plt.subplots(figsize=(11, 9))
cmap = sns.diverging_palette(230, 20, as_cmap=True)
heatmap=sns.heatmap(corr, mask=mask, cmap=cmap, vmax=.3, center=0,
            square=True, linewidths=.5, cbar_kws={"shrink": .5})
heatmap = heatmap.get_figure()<jupyter_output><empty_output><jupyter_text>As mention on the state health correlation people with mental problems, no health problems, comorbidities mostly obesity have a higher probability of contracting the virus and dying from it, the use of the municipality data reaffirms this because there is more data to correlate and the correlation is still positive.  Heatmap of Socioeconomic and Education variables correlation with case/death rate All the variables related to socioeconomic and education factors and the case/death rate are selected<jupyter_code>dfSocioeconomicEducation = dfAll[['case_rate', 'case_rate_last_60_days',
       'death_rate', 'death_rate_last_60_days','pct_no_med_insurance',
       'pct_med_insurance','average_years_finish','average_household_size', 
       'pct_household_tics','pct_household_no_tics']].copy()<jupyter_output><empty_output><jupyter_text>The correlation between the socioeconomic and education factors and the case/death rate is as following<jupyter_code>corr = dfSocioeconomicEducation.corr()
mask = np.triu(np.ones_like(corr, dtype=bool))
f, ax = plt.subplots(figsize=(11, 9))
cmap = sns.diverging_palette(230, 20, as_cmap=True)
heatmap=sns.heatmap(corr, mask=mask, cmap=cmap, vmax=.3, center=0,
            square=True, linewidths=.5, cbar_kws={"shrink": .5})
heatmap = heatmap.get_figure()<jupyter_output><empty_output><jupyter_text>The same behaviour occurs in the municipality level as the state level where the people with medical insurance, househouseholds with TIC's and high level of education which are all on urban areas which are highly transited meaning they have a high probability of infection and in the case of people with no medical insurance and households wit no TIC's is viceversa because they are located on urban areas which have a low transit meaning they have a low probability of infection.  Heatmap of population variables correlation with case/death rate All the variables related to population factors and the case/death rate are selected<jupyter_code>dfPopulation = dfAll[['case_rate','case_rate_last_60_days',
       'death_rate', 'death_rate_last_60_days',
       'population/sqkm']].copy()<jupyter_output><empty_output><jupyter_text>The correlation between the population factors and the case/death rate is as following<jupyter_code>corr = dfPopulation.corr()
mask = np.triu(np.ones_like(corr, dtype=bool))
f, ax = plt.subplots(figsize=(11, 9))
cmap = sns.diverging_palette(230, 20, as_cmap=True)
heatmap=sns.heatmap(corr, mask=mask, cmap=cmap, vmax=.3, center=0,
            square=True, linewidths=.5, cbar_kws={"shrink": .5})
heatmap = heatmap.get_figure()<jupyter_output><empty_output><jupyter_text>In this case the mobility was not one of the variables because there was not a data source that provided this variables, but even tough the population density also corroborated that the state analyzes is correct mening that where is a high poulation density area there is a high probability of getting infected and dying on it due the high transit. The variables and the region codes are selected of the dataframe for future storage<jupyter_code>dfFinal = dfAll[['cve_ent', 'case_rate', 'case_rate_last_60_days',
       'death_rate', 'death_rate_last_60_days',
       'pct_disability', 'pct_limitation', 'pct_mental_problem',
       'pct_no_problems', 'pct_no_med_insurance','pct_med_insurance',
        'pct_pop_obesity', 'pct_pop_hypertension',
       'pct_pop_diabetes',
       'average_years_finish','average_household_size', 'pct_household_tics','pct_household_no_tics', 
       'population/sqkm']].copy()<jupyter_output><empty_output><jupyter_text>The dataframe is stored<jupyter_code>dfFinal.to_csv('../data/week3analyzesMunicipalities.csv',index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09331312110493516, 'fraction_numerical': 0.010274549435741957, 'mean_word_length': 6.772251308900524, 'pattern_counts': {'":': 3, '<': 45, '<?xml version=': 0, '>': 45, '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': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '519481', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 2021, 'n_tokens_neox': 1874, 'n_words': 504, 'path': 'Notebooks/Week3Municipalities.ipynb', 'repo_name': 'Angel-VB/enlace2021_av', 'size': '5937'}