<jupyter_start><jupyter_text>Correlation of COVID-19 cases in the states of Mexico by level of education<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

sns.set_theme(style="white")

%matplotlib inline
%reload_ext autoreload
%autoreload 2<jupyter_output><empty_output><jupyter_text>Import COVID-19 cases data<jupyter_code>dfcvcases = pd.read_csv('../Data/week1analyzes.csv')
dfcvcases.head()<jupyter_output><empty_output><jupyter_text>Import level of education data<jupyter_code>dflevschool = pd.read_excel('../Data/Educacion_04.xlsx', skiprows = range(0, 3))
dflevschool.head()
dfls=dflevschool.loc[:, ['Entidad federativa', 'Total', 'Sin escolaridad', 'Primaria', 'Preparatoria o bachillerato', 'Licenciatura o equivalente', 'Posgrado']]
dfls.head()
dfls.rename(columns={'Entidad federativa': 'state', 'Sin escolaridad': 'not_school', 'Primaria': 'elementary_school', 'Preparatoria o bachillerato': 'high_school', 'Licenciatura o equivalente': 'bachelor', 'Posgrado': 'postgraduate', 'Total': 'Total'}, inplace=True)
dfls.head()
dfls.query('state != "Estados Unidos Mexicanos"', inplace=True)
dfls.head()
dfls['state']=dfls['state'].str.upper()
dfls.head()
dfls = dfls.iloc[0:32,:].copy()
dfls.sort_values(by=['state'], ascending = True, inplace=True)
dfls.at[9,'state']='DISTRITO FEDERAL'
dfls.at[5,'state']='COAHUILA'
dfls.at[15,'state']='MEXICO'
dfls.at[16,'state']='MICHOACAN'
dfls.at[30,'state']='VERACRUZ'
dfls.at[22,'state']='QUERETARO'
dfls.at[24,'state']='SAN LUIS POTOSI'
dfls.at[31,'state']='YUCATAN'
dfls.at[19,'state']='NUEVO LEON'
dfls.sort_values(by=['state'], ascending = True, inplace=True)
dfls.head()
dfls['pct_not_school']=dfls['not_school']/dfls['Total']*100
dfls['pct_elementary_school']=dfls['elementary_school']/dfls['Total']*100
dfls['pct_high_school']=dfls['high_school']/dfls['Total']*100
dfls['pct_bachelor']=dfls['bachelor']/dfls['Total']*100
dfls['pct_postgraduate']=dfls['postgraduate']/dfls['Total']*100
dfls.head()
dflspct=dfls.loc[:, ['state', 'pct_not_school', 'pct_elementary_school', 'pct_high_school', 'pct_bachelor', 'pct_postgraduate', 'Total']]
dflspct.head()<jupyter_output><empty_output><jupyter_text>Merge Dataframes (COVID Cases / level of education)<jupyter_code>dfAll = pd.merge(dfcvcases, dflspct,  on='state')
dfAll.head()
dfAll.shape
# Compute the correlation matrix
corr = dfAll.corr()

# Generate a mask for the upper triangle
mask = np.triu(np.ones_like(corr, dtype=bool))

# Set up the matplotlib figure
f, ax = plt.subplots(figsize=(11, 9))

# Generate a custom diverging colormap
cmap = sns.diverging_palette(230, 20, as_cmap=True)

# Draw the heatmap with the mask and correct aspect ratio
sns.heatmap(corr, mask=mask, cmap=cmap, vmax=.3, center=0,
            square=True, linewidths=.5, cbar_kws={"shrink": .5})<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17266689968542467, 'fraction_numerical': 0.019573575672841664, 'mean_word_length': 8.66891891891892, 'pattern_counts': {'":': 1, '<': 17, '<?xml version=': 0, '>': 17, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '282563', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1166, 'n_words': 197, 'path': 'Notebooks/prev/Week2_LevelSchool.ipynb', 'repo_name': 'Angel-VB/enlace2021_av', 'size': '2861'}