<jupyter_start><jupyter_text>CENSO 2017<jupyter_code>import pandas as pd
import pandas_gbq
import geopandas as gpd

path_base = '/Users/pipe/Documents/Spike/CR2/calidad_aire_2050_cr2/'
df = pd.read_csv(f'{path_base}datos_streamlit/Censo2017_Manzanas.csv', sep=';')


df.replace({'*':0}, inplace=True)
for col in ['PUEBLO','PERSONAS','INMIGRANTES']:
    df[col] = df[col].astype('int')


# Comunas
comunas = gpd.read_file(f'{path_base}datos_streamlit/Comunas/comunas.shp')
comunas.columns = [m.lower() for m in comunas.columns]
comunas = comunas.to_crs({'init': 'epsg:4326'})
comunas['centroide_comuna_x'] = comunas.centroid.x
comunas['centroide_comuna_y'] = comunas.centroid.y

socioec = datos_socioec
socioec.columns = ['cod_comuna', 'personas','pueblo_indigena', 'inmigrantes']
consolidado = socioec.merge(comunas[['cod_comuna','comuna','provincia','region',
                                     'centroide_comuna_x','centroide_comuna_y']], on='cod_comuna', how='left')
pandas_gbq.to_gbq(consolidado, 'CR2.habitantes_por_comuna', project_id='spike-sandbox', if_exists='replace')<jupyter_output>1it [00:04,  4.24s/it]
{'fraction_non_alphanumeric': 0.16279069767441862, 'fraction_numerical': 0.025044722719141325, 'mean_word_length': 6.5608108108108105, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '297292', 'license': 'MIT', 'n_tokens_mistral': 491, 'n_tokens_neox': 471, 'n_words': 57, 'path': 'notebooks/subir_personas_bq.ipynb', 'repo_name': 'SpikeLab-CL/calidad_aire_2050_cr2', 'size': '1118'}