Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
robertopucp
GitHub Repository: robertopucp/1eco35_2022_2
Path: blob/main/Trabajo_grupal/WG3/Grupo_10_py_version final.ipynb
2714 views
Kernel: Python 3 (ipykernel)

TAREA 3_ GRUPO 10

import numpy as np import pandas as pd from pandas import DataFrame,Series
junin_data = pd.read_excel("../data/Region_Junin.xlsx")
#Pregunta 1: Obtener el nombre de todas las variables list(junin_data.columns)
['Unnamed: 0', 'Region', 'District', 'Place', '4_6_years_men', '4_6_years_women', '4_6_years_total', '6_14_years_men', '6_14_years_women', '6_14_years_total', 'man_read', 'women_read', 'total_read', 'men_not_read', 'women_not_read', 'total_not_read', 'man_write', 'women_write', 'total_write', 'men_not_write', 'women_not_write', 'total_not_write', 'instruction_men', 'instruction_women', 'instruction_total', 'no_instruction_men', 'no_instruction_women', 'no_instruction_total', 'finished_instr_men', 'finished_instr_women', 'finished_instr_total', 'not_finished_instr_men', 'not_finished_instr_women', 'not_finished_instr_total', 'peruvian_men', 'peruvian_women', 'foreign_men', 'foreign_women', 'whites', 'natives', 'mestizos', 'blacks']
#Pregunta 2: Mostrar el tipo de variables (type) así como presentar los principales estadísticos. junin_data.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 197 entries, 0 to 196 Data columns (total 42 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Unnamed: 0 197 non-null int64 1 Region 197 non-null object 2 District 197 non-null object 3 Place 186 non-null object 4 4_6_years_men 197 non-null int64 5 4_6_years_women 197 non-null int64 6 4_6_years_total 197 non-null int64 7 6_14_years_men 196 non-null float64 8 6_14_years_women 197 non-null int64 9 6_14_years_total 197 non-null int64 10 man_read 197 non-null int64 11 women_read 193 non-null float64 12 total_read 197 non-null int64 13 men_not_read 197 non-null int64 14 women_not_read 197 non-null int64 15 total_not_read 196 non-null float64 16 man_write 196 non-null float64 17 women_write 196 non-null float64 18 total_write 192 non-null float64 19 men_not_write 191 non-null float64 20 women_not_write 197 non-null int64 21 total_not_write 194 non-null float64 22 instruction_men 197 non-null int64 23 instruction_women 195 non-null float64 24 instruction_total 195 non-null float64 25 no_instruction_men 194 non-null float64 26 no_instruction_women 197 non-null int64 27 no_instruction_total 197 non-null int64 28 finished_instr_men 194 non-null float64 29 finished_instr_women 192 non-null float64 30 finished_instr_total 196 non-null float64 31 not_finished_instr_men 196 non-null float64 32 not_finished_instr_women 196 non-null float64 33 not_finished_instr_total 196 non-null float64 34 peruvian_men 196 non-null float64 35 peruvian_women 196 non-null float64 36 foreign_men 196 non-null float64 37 foreign_women 195 non-null float64 38 whites 196 non-null float64 39 natives 191 non-null float64 40 mestizos 195 non-null float64 41 blacks 197 non-null int64 dtypes: float64(24), int64(15), object(3) memory usage: 64.8+ KB
#Pregunta 3: Verifique si las columnas presentan valores faltantes print(junin_data.isna().sum())
Unnamed: 0 0 Region 0 District 0 Place 11 4_6_years_men 0 4_6_years_women 0 4_6_years_total 0 6_14_years_men 1 6_14_years_women 0 6_14_years_total 0 man_read 0 women_read 4 total_read 0 men_not_read 0 women_not_read 0 total_not_read 1 man_write 1 women_write 1 total_write 5 men_not_write 6 women_not_write 0 total_not_write 3 instruction_men 0 instruction_women 2 instruction_total 2 no_instruction_men 3 no_instruction_women 0 no_instruction_total 0 finished_instr_men 3 finished_instr_women 5 finished_instr_total 1 not_finished_instr_men 1 not_finished_instr_women 1 not_finished_instr_total 1 peruvian_men 1 peruvian_women 1 foreign_men 1 foreign_women 2 whites 1 natives 6 mestizos 2 blacks 0 dtype: int64
#Pregunta 4: Cambie el nombre de las siguientes variables junin_data.rename(columns = {'Place':'comunidad', 'men_not_read':'homxlee', 'women_not_read':'mujerxlee', 'total_not_read':'totalxlee'}, inplace = True)
#Pregunta 5: Muestre los valores únicos de las siguientes variables ( comunidad , District) print(junin_data.comunidad.unique()) print(junin_data.District.unique())
['C.CIUDAD DEL CERRO' 'P.YANACANCHA' 'VICO' 'RANCA' 'PASCO' nan 'CAJAMARQUILLA' 'CAICO' 'ROCO' 'P.QUINUA' 'H.PARIAHUANCA' 'P.SULLUMARCA' 'H.SAN ANDRÉS' 'P.HUALLAY' 'C.HUAYCHAO' 'COCHAMARCA' 'P.CHACAYÁN' 'VILCABAMBA' 'CUCHES' 'CHANGO' 'MITO' 'ANTAPIRCA' 'P.CAYNA' 'A. COLPAS' 'C.MASQUIN' 'P.YAMOR' 'TANGOR' 'QUIO' 'CAURY' 'CHUCCHUC' 'COQUIN' 'A.YAPOC' 'P.YANAHUANCA' 'HUAYLACIRCA' 'HUARANTAMBO' 'ANDUCHACA' 'VILLO' 'MICHIVILCA' 'PILLAO' 'YACÁN' 'TÁPUC' 'CHAUPIMARCA' 'P.OXAPAMPA' 'P.JAUJA' 'A.CHUNÁN' 'C.PACAPACHA' 'HUANCAS' 'A.HUERTAS' 'PACA' 'MASMA' 'ATAURA' 'HUALÁ' 'JULCÁN' 'P.RICRÁN' 'A.PAUCÁN' 'P.APATA' 'HUAMALÍ' 'A.SAN LORENZO' 'PACUCHO' 'P.ORCOTUNA' 'A.VICSO' 'TISTES' 'P.HUARIPAMPA' 'A.PARCO' 'PACCHA' 'CANCHAPUNCO' 'C.ULLUSCA' 'CANCHAS' 'P.MUQUIYAUYO' 'MUQUI' 'P.ACOLLA' 'MARCO' 'TRAGADERO' 'ACAYA' 'YAUJAILLO' 'CURICACA' 'C.LLACUARI' 'P.HUANCARÍ' 'C.CHALHUAS' 'ARAMACHAY' 'P.MITO' 'A.CHAMBARÁ' 'C.QUICHA' 'HUACHAC' 'A.ACO' 'P.LLOCLLAPAMPA' 'VISCAS ESPERANZA' 'CONCHAILLO' 'MATA-CHICO' 'MATA-GRANDE' 'P.CONCEPCIÓN' 'SANTA ROSA DE OCOPA' 'HUANTAR' 'A.ALAYO' 'C.SAN ANTONIO DE CARICANCHO' 'SANTO DOMINGO' 'P.CÓMAS' 'C.CHUPA' 'COCHAS' 'P.MATAHUASI' 'P.HUANCAYO' 'CAJAS' 'P.CHUPACA' 'A.ISCOS' 'ANTAPAMPA' 'HUAUSCA GRANDE' 'SAN JUAN DE TARPA' 'COPCA' 'HUAYAN' 'HUAMANCACA' 'PILCOMAYO' 'AHUAC' 'ACAC' 'P.SAN GERÓNIMO' 'HUALHUAS' 'SAN PEDRO DE SAÑO' 'QUICHUAY' 'CASACANCHA' 'A.INGENIO' 'P.SANTA CRUZ DE QUILCAY' 'RANGRA' 'P.SAPALLANGA' 'A.LA PUNTA' 'P.PUCARÁ' 'C.PATALÁ' 'MARCAVALLE' 'COCHARCAS' 'P.CHONGOS' 'C.TURPAC Y TINYARI' 'SOCOS' 'PUMPUNGA' 'CHUPURO' 'CARHUAPACHA' 'A.HUAMANCACA' 'P.SICAYA' 'A.HUANCHAC' 'C.CACHICAMARCA' 'P.COLCA' 'A.CHACAPAMPA' 'HUASICANCHA' 'CUCHO' 'CHILIAY' 'POTACA' 'LARIA' 'CHONGOS ALTO' 'P.HUAYUCACHI' 'HUAMANMARCA' 'CACAS' 'HUARAPUQUIO' 'CULLHUAS' 'RETAMA' 'PACHA' 'P.TARMA' 'MACO' 'MULLUERO' 'CHANCHA' 'TARMATAMBO' 'P.JUNÍN' 'HUASAHUASY' 'PARI' 'YANEC' 'CHUPÁN' 'ACONCOCHA' 'ONDORES' 'P.ACOBAMBA' 'PICOY' 'C.HUARACAYO' 'A.PALCA' 'C.HUAILAHUICHÁN' 'P.PALCAMAYO' 'P.OROYA' 'HUAYNACANCHA' 'HUAYHUAY' 'P.CARHUAMAYO' 'ULCUMAYO' 'P.SAN RAMÓN' 'P.VISCATÁN' 'PAN DE AZÚCAR' 'SUITUCANCHA' 'CHACAPALCA' 'P.POMACOCHA' 'YAULI' 'MINAS DE MOROCOCHA'] ['CIUDAD DEL CERRO' 'HUAYLLAY' 'CHACAYÁN' 'CAYNA' 'YANAHUANCA' 'NINACACA' 'JAUJA' 'APATA' 'ORCOTUNA' 'HUARIPAMPA' 'MUQUIYAUYO' 'ACOLLA' 'CINCOS' 'MITO' 'LLOCLLAPAMPA' 'CONCEPCIÓN' 'COCHAS' 'MATAHUASI' 'HUANCAYO' 'CHUPACA' 'SAN GERÓNIMO' 'SAPALLANGA' 'CHONGOS' 'SICAYA' 'COLCA' 'HUAYUCACHI' 'TARMA' 'JUNÍN' 'ACOBAMBA' 'OROYA' 'CARHUAMAYO' 'CHANCHAMAYO' 'VITOC' 'CHACAPALCA' 'YAULI']
# pregunta 5: total de valores únicos print (len(junin_data.comunidad.unique())) print (len(junin_data.District.unique()))
183 35
# Pregunta 6: Crear columnas con las siguiente información: # a. % de mujeres del que no escriben ni leen (mujerxlee/totalxlee) junin_data['% de mujeres del que no escriben ni leen'] = junin_data['mujerxlee']*100 / junin_data['totalxlee']
# b. % de varones que no escriben ni leen (homxlee/totalxlee) junin_data['% de varones del que no escriben ni leen'] = junin_data['homxlee']*100 / junin_data['totalxlee']
# c. % de nativos respecto al total de la población. Para el total de la población sumar (peruvian_men +peruvian_women + foreign_men + foreign_women) junin_data['total de la población'] = junin_data['peruvian_men' ] + junin_data['peruvian_women'] + junin_data['foreign_men'] + junin_data['foreign_women'] junin_data['% de nativos respecto al total de la población'] = junin_data['natives']*100 / junin_data['total de la población']
# Pregunta 7: Crear una base de datos con la siguiente información: # a. Quedarse con la información de los distritos de Ciudad del Cerro, Jauja, Acolla, San Gerónimo, Tarma, Oroya y Concepción print (junin_data.loc[0:13]) print (junin_data.loc[47:58]) print (junin_data.loc[74:80]) print (junin_data.loc[96:101]) print (junin_data.loc[161:166]) print (junin_data.loc[181:184])
Unnamed: 0 Region District comunidad 4_6_years_men \ 0 0 JUNIN CIUDAD DEL CERRO C.CIUDAD DEL CERRO 65 1 1 JUNIN CIUDAD DEL CERRO P.YANACANCHA 1 2 2 JUNIN CIUDAD DEL CERRO VICO 1 3 3 JUNIN CIUDAD DEL CERRO RANCA 0 4 4 JUNIN CIUDAD DEL CERRO PASCO 4 5 5 JUNIN CIUDAD DEL CERRO NaN 6 6 6 JUNIN CIUDAD DEL CERRO CAJAMARQUILLA 9 7 7 JUNIN CIUDAD DEL CERRO CAICO 18 8 8 JUNIN CIUDAD DEL CERRO ROCO 7 9 9 JUNIN CIUDAD DEL CERRO NaN 16 10 10 JUNIN CIUDAD DEL CERRO P.QUINUA 8 11 11 JUNIN CIUDAD DEL CERRO H.PARIAHUANCA 2 12 12 JUNIN CIUDAD DEL CERRO P.SULLUMARCA 12 13 13 JUNIN CIUDAD DEL CERRO H.SAN ANDRÉS 8 4_6_years_women 4_6_years_total 6_14_years_men 6_14_years_women \ 0 46 111 297.0 171 1 3 4 49.0 47 2 0 1 46.0 25 3 6 6 25.0 19 4 4 8 21.0 21 5 7 13 44.0 43 6 8 17 31.0 39 7 23 41 90.0 77 8 4 11 42.0 19 9 8 24 26.0 25 10 6 14 17.0 19 11 6 8 10.0 12 12 14 26 38.0 32 13 0 8 17.0 25 6_14_years_total ... foreign_men foreign_women whites natives \ 0 468 ... 1.0 1.0 4.0 284.0 1 96 ... 0.0 0.0 0.0 100.0 2 71 ... 0.0 0.0 0.0 69.0 3 44 ... 0.0 0.0 0.0 25.0 4 42 ... 0.0 0.0 0.0 37.0 5 87 ... 0.0 0.0 0.0 65.0 6 70 ... 0.0 0.0 0.0 87.0 7 167 ... 0.0 0.0 4.0 175.0 8 61 ... 0.0 0.0 0.0 70.0 9 51 ... 0.0 0.0 0.0 73.0 10 36 ... 0.0 0.0 0.0 50.0 11 22 ... 0.0 0.0 0.0 NaN 12 70 ... 0.0 0.0 0.0 96.0 13 42 ... 0.0 0.0 0.0 44.0 mestizos blacks % de mujeres del que no escriben ni leen \ 0 290.0 1 41.210375 1 0.0 0 71.428571 2 3.0 0 53.191489 3 25.0 0 100.000000 4 13.0 0 53.191489 5 35.0 0 55.421687 6 0.0 0 54.022989 7 29.0 0 51.315789 8 NaN 0 30.000000 9 NaN 0 44.594595 10 0.0 0 50.000000 11 6.0 0 60.000000 12 0.0 0 47.916667 13 6.0 0 53.191489 % de varones del que no escriben ni leen total de la población \ 0 58.789625 579.0 1 28.571429 100.0 2 46.808511 72.0 3 0.000000 50.0 4 46.808511 50.0 5 44.578313 100.0 6 45.977011 87.0 7 48.684211 208.0 8 70.000000 72.0 9 55.405405 75.0 10 50.000000 50.0 11 40.000000 30.0 12 52.083333 96.0 13 46.808511 NaN % de nativos respecto al total de la población 0 49.050086 1 100.000000 2 95.833333 3 50.000000 4 74.000000 5 65.000000 6 100.000000 7 84.134615 8 97.222222 9 97.333333 10 100.000000 11 NaN 12 100.000000 13 NaN [14 rows x 46 columns] Unnamed: 0 Region District comunidad 4_6_years_men 4_6_years_women \ 47 47 JUNIN JAUJA P.JAUJA 69 71 48 48 JUNIN JAUJA A.CHUNÁN 12 11 49 49 JUNIN JAUJA C.PACAPACHA 1 7 50 50 JUNIN JAUJA HUANCAS 3 2 51 51 JUNIN JAUJA A.HUERTAS 22 38 52 52 JUNIN JAUJA PACA 1 4 53 53 JUNIN JAUJA MASMA 27 15 54 54 JUNIN JAUJA ATAURA 24 22 55 55 JUNIN JAUJA HUALÁ 9 9 56 56 JUNIN JAUJA JULCÁN 19 11 57 57 JUNIN JAUJA P.RICRÁN 36 21 58 58 JUNIN JAUJA A.PAUCÁN 21 13 4_6_years_total 6_14_years_men 6_14_years_women 6_14_years_total ... \ 47 140 375.0 327 702 ... 48 23 45.0 21 66 ... 49 8 24.0 18 42 ... 50 5 29.0 40 69 ... 51 60 103.0 87 190 ... 52 5 84.0 52 136 ... 53 42 148.0 139 287 ... 54 46 74.0 68 142 ... 55 18 57.0 28 85 ... 56 30 106.0 144 250 ... 57 57 98.0 93 191 ... 58 34 85.0 69 154 ... foreign_men foreign_women whites natives mestizos blacks \ 47 0.0 0.0 63.0 117.0 662.0 0 48 0.0 0.0 0.0 89.0 0.0 0 49 0.0 NaN 0.0 50.0 0.0 0 50 0.0 0.0 0.0 74.0 0.0 0 51 0.0 0.0 0.0 195.0 55.0 0 52 0.0 0.0 6.0 141.0 0.0 0 53 0.0 0.0 0.0 294.0 29.0 0 54 0.0 0.0 NaN 104.0 84.0 0 55 0.0 0.0 0.0 99.0 4.0 0 56 0.0 NaN 0.0 178.0 72.0 0 57 0.0 0.0 0.0 240.0 8.0 0 58 0.0 0.0 0.0 65.0 123.0 0 % de mujeres del que no escriben ni leen \ 47 54.797980 48 52.459016 49 75.757576 50 68.852459 51 73.548387 52 84.848485 53 63.362069 54 54.814815 55 55.737705 56 72.258065 57 54.901961 58 58.992806 % de varones del que no escriben ni leen total de la población \ 47 45.202020 842.0 48 47.540984 89.0 49 24.242424 NaN 50 31.147541 74.0 51 26.451613 250.0 52 15.151515 141.0 53 36.637931 329.0 54 45.185185 188.0 55 44.262295 103.0 56 27.741935 NaN 57 45.098039 248.0 58 41.007194 188.0 % de nativos respecto al total de la población 47 13.895487 48 100.000000 49 NaN 50 100.000000 51 78.000000 52 100.000000 53 89.361702 54 55.319149 55 96.116505 56 NaN 57 96.774194 58 34.574468 [12 rows x 46 columns] Unnamed: 0 Region District comunidad 4_6_years_men 4_6_years_women \ 74 74 JUNIN ACOLLA P.ACOLLA 45 38 75 75 JUNIN ACOLLA MARCO 16 12 76 76 JUNIN ACOLLA TRAGADERO 20 13 77 77 JUNIN ACOLLA NaN 2 0 78 78 JUNIN ACOLLA ACAYA 2 2 79 79 JUNIN ACOLLA YAUJAILLO 11 2 80 80 JUNIN ACOLLA CURICACA 8 3 4_6_years_total 6_14_years_men 6_14_years_women 6_14_years_total ... \ 74 83 160.0 117 277 ... 75 28 94.0 55 149 ... 76 33 87.0 52 139 ... 77 2 16.0 22 38 ... 78 4 29.0 21 50 ... 79 13 13.0 4 17 ... 80 11 25.0 10 35 ... foreign_men foreign_women whites natives mestizos blacks \ 74 0.0 0.0 0.0 333.0 27.0 0 75 0.0 0.0 0.0 167.0 10.0 0 76 0.0 0.0 0.0 169.0 3.0 0 77 0.0 0.0 0.0 0.0 0.0 0 78 0.0 0.0 0.0 54.0 0.0 0 79 0.0 0.0 0.0 30.0 0.0 0 80 0.0 0.0 0.0 46.0 0.0 0 % de mujeres del que no escriben ni leen \ 74 53.198653 75 46.853147 76 60.784314 77 57.894737 78 48.936170 79 22.222222 80 46.428571 % de varones del que no escriben ni leen total de la población \ 74 46.801347 360.0 75 53.146853 177.0 76 39.215686 172.0 77 42.105263 40.0 78 51.063830 54.0 79 77.777778 30.0 80 53.571429 46.0 % de nativos respecto al total de la población 74 92.500000 75 94.350282 76 98.255814 77 0.000000 78 100.000000 79 100.000000 80 100.000000 [7 rows x 46 columns] Unnamed: 0 Region District comunidad \ 96 96 JUNIN CONCEPCIÓN P.CONCEPCIÓN 97 97 JUNIN CONCEPCIÓN SANTA ROSA DE OCOPA 98 98 JUNIN CONCEPCIÓN HUANTAR 99 99 JUNIN CONCEPCIÓN A.ALAYO 100 100 JUNIN CONCEPCIÓN C.SAN ANTONIO DE CARICANCHO 101 101 JUNIN CONCEPCIÓN SANTO DOMINGO 4_6_years_men 4_6_years_women 4_6_years_total 6_14_years_men \ 96 38 43 81 178.0 97 28 32 60 95.0 98 3 0 3 47.0 99 3 8 11 22.0 100 10 8 18 68.0 101 16 11 27 30.0 6_14_years_women 6_14_years_total ... foreign_men foreign_women \ 96 164 342 ... 0.0 0.0 97 93 188 ... 0.0 0.0 98 41 88 ... 0.0 0.0 99 29 51 ... 0.0 0.0 100 46 114 ... 0.0 0.0 101 41 71 ... 0.0 0.0 whites natives mestizos blacks \ 96 0.0 141.0 282.0 0 97 0.0 183.0 65.0 0 98 0.0 90.0 1.0 0 99 0.0 62.0 0.0 0 100 0.0 0.0 0.0 0 101 0.0 98.0 0.0 0 % de mujeres del que no escriben ni leen \ 96 55.629139 97 63.101604 98 70.909091 99 NaN 100 51.923077 101 54.166667 % de varones del que no escriben ni leen total de la población \ 96 44.370861 423.0 97 36.898396 248.0 98 29.090909 91.0 99 NaN 62.0 100 48.076923 132.0 101 45.833333 98.0 % de nativos respecto al total de la población 96 33.333333 97 73.790323 98 98.901099 99 100.000000 100 0.000000 101 100.000000 [6 rows x 46 columns] Unnamed: 0 Region District comunidad 4_6_years_men 4_6_years_women \ 161 161 JUNIN TARMA P.TARMA 107 117 162 162 JUNIN TARMA MACO 28 12 163 163 JUNIN TARMA MULLUERO 11 14 164 164 JUNIN TARMA NaN 7 6 165 165 JUNIN TARMA CHANCHA 17 20 166 166 JUNIN TARMA TARMATAMBO 3 1 4_6_years_total 6_14_years_men 6_14_years_women 6_14_years_total ... \ 161 224 386.0 427 813 ... 162 40 72.0 52 124 ... 163 25 114.0 73 187 ... 164 13 68.0 52 120 ... 165 37 122.0 77 199 ... 166 4 72.0 32 104 ... foreign_men foreign_women whites natives mestizos blacks \ 161 3.0 1.0 158.0 189.0 689.0 1 162 0.0 0.0 0.0 164.0 0.0 0 163 0.0 0.0 0.0 179.0 33.0 0 164 0.0 0.0 0.0 91.0 42.0 0 165 0.0 0.0 0.0 228.0 8.0 0 166 0.0 0.0 0.0 108.0 0.0 0 % de mujeres del que no escriben ni leen \ 161 58.110517 162 50.000000 163 46.236559 164 60.000000 165 46.634615 166 41.772152 % de varones del que no escriben ni leen total de la población \ 161 41.889483 1037.0 162 50.000000 164.0 163 53.763441 212.0 164 40.000000 133.0 165 53.365385 236.0 166 58.227848 108.0 % de nativos respecto al total de la población 161 18.225651 162 100.000000 163 84.433962 164 68.421053 165 96.610169 166 100.000000 [6 rows x 46 columns] Unnamed: 0 Region District comunidad 4_6_years_men 4_6_years_women \ 181 181 JUNIN OROYA P.OROYA 11 9 182 182 JUNIN OROYA HUAYNACANCHA 4 2 183 183 JUNIN OROYA PACHA 2 4 184 184 JUNIN OROYA HUAYHUAY 13 8 4_6_years_total 6_14_years_men 6_14_years_women 6_14_years_total ... \ 181 20 41.0 35 76 ... 182 6 11.0 16 27 ... 183 6 7.0 3 10 ... 184 21 55.0 33 88 ... foreign_men foreign_women whites natives mestizos blacks \ 181 0.0 0.0 15.0 28.0 53.0 0 182 0.0 0.0 0.0 33.0 0.0 0 183 0.0 0.0 0.0 16.0 0.0 0 184 0.0 0.0 0.0 108.0 1.0 0 % de mujeres del que no escriben ni leen \ 181 36.538462 182 54.545455 183 43.750000 184 61.818182 % de varones del que no escriben ni leen total de la población \ 181 63.461538 96.0 182 45.454545 33.0 183 56.250000 16.0 184 38.181818 109.0 % de nativos respecto al total de la población 181 29.166667 182 100.000000 183 100.000000 184 99.082569 [4 rows x 46 columns]
#b. Luego quedarse con las comunidades que cuentan con nativos y mestizos. print (junin_data.dropna(axis = 0)) print (junin_data.loc[:,['comunidad','natives','mestizos']])
Unnamed: 0 Region District comunidad 4_6_years_men \ 0 0 JUNIN CIUDAD DEL CERRO C.CIUDAD DEL CERRO 65 1 1 JUNIN CIUDAD DEL CERRO P.YANACANCHA 1 2 2 JUNIN CIUDAD DEL CERRO VICO 1 3 3 JUNIN CIUDAD DEL CERRO RANCA 0 4 4 JUNIN CIUDAD DEL CERRO PASCO 4 .. ... ... ... ... ... 191 191 JUNIN CHACAPALCA SUITUCANCHA 0 192 192 JUNIN CHACAPALCA CHACAPALCA 1 193 193 JUNIN YAULI P.POMACOCHA 1 195 195 JUNIN YAULI YAULI 2 196 196 JUNIN YAULI MINAS DE MOROCOCHA 9 4_6_years_women 4_6_years_total 6_14_years_men 6_14_years_women \ 0 46 111 297.0 171 1 3 4 49.0 47 2 0 1 46.0 25 3 6 6 25.0 19 4 4 8 21.0 21 .. ... ... ... ... 191 4 4 25.0 33 192 0 1 71.0 0 193 0 1 15.0 7 195 6 8 74.0 38 196 5 14 87.0 25 6_14_years_total ... foreign_men foreign_women whites natives \ 0 468 ... 1.0 1.0 4.0 284.0 1 96 ... 0.0 0.0 0.0 100.0 2 71 ... 0.0 0.0 0.0 69.0 3 44 ... 0.0 0.0 0.0 25.0 4 42 ... 0.0 0.0 0.0 37.0 .. ... ... ... ... ... ... 191 58 ... 0.0 0.0 0.0 33.0 192 71 ... 0.0 0.0 0.0 35.0 193 22 ... 0.0 0.0 0.0 21.0 195 112 ... 0.0 0.0 37.0 14.0 196 112 ... 0.0 0.0 1.0 118.0 mestizos blacks % de mujeres del que no escriben ni leen \ 0 290.0 1 41.210375 1 0.0 0 71.428571 2 3.0 0 53.191489 3 25.0 0 100.000000 4 13.0 0 53.191489 .. ... ... ... 191 29.0 0 100.000000 192 39.0 0 0.000000 193 2.0 0 46.666667 195 69.0 0 38.596491 196 7.0 0 25.423729 % de varones del que no escriben ni leen total de la población \ 0 58.789625 579.0 1 28.571429 100.0 2 46.808511 72.0 3 0.000000 50.0 4 46.808511 50.0 .. ... ... 191 0.000000 62.0 192 100.000000 72.0 193 53.333333 23.0 195 61.403509 120.0 196 74.576271 126.0 % de nativos respecto al total de la población 0 49.050086 1 100.000000 2 95.833333 3 50.000000 4 74.000000 .. ... 191 53.225806 192 48.611111 193 91.304348 195 11.666667 196 93.650794 [141 rows x 46 columns] comunidad natives mestizos 0 C.CIUDAD DEL CERRO 284.0 290.0 1 P.YANACANCHA 100.0 0.0 2 VICO 69.0 3.0 3 RANCA 25.0 25.0 4 PASCO 37.0 13.0 .. ... ... ... 192 CHACAPALCA 35.0 39.0 193 P.POMACOCHA 21.0 2.0 194 NaN 0.0 26.0 195 YAULI 14.0 69.0 196 MINAS DE MOROCOCHA 118.0 7.0 [197 rows x 3 columns]
#c. Solo quedarse con las variables trabajadas en el punto 6), nombre de distrito y comunidad. print (junin_data.loc[:,['% de nativos respecto al total de la población','% de varones del que no escriben ni leen','% de mujeres del que no escriben ni leen','District','comunidad']])
% de nativos respecto al total de la población \ 0 49.050086 1 100.000000 2 95.833333 3 50.000000 4 74.000000 .. ... 192 48.611111 193 91.304348 194 0.000000 195 11.666667 196 93.650794 % de varones del que no escriben ni leen \ 0 58.789625 1 28.571429 2 46.808511 3 0.000000 4 46.808511 .. ... 192 100.000000 193 53.333333 194 68.181818 195 61.403509 196 74.576271 % de mujeres del que no escriben ni leen District \ 0 41.210375 CIUDAD DEL CERRO 1 71.428571 CIUDAD DEL CERRO 2 53.191489 CIUDAD DEL CERRO 3 100.000000 CIUDAD DEL CERRO 4 53.191489 CIUDAD DEL CERRO .. ... ... 192 0.000000 CHACAPALCA 193 46.666667 YAULI 194 31.818182 YAULI 195 38.596491 YAULI 196 25.423729 YAULI comunidad 0 C.CIUDAD DEL CERRO 1 P.YANACANCHA 2 VICO 3 RANCA 4 PASCO .. ... 192 CHACAPALCA 193 P.POMACOCHA 194 NaN 195 YAULI 196 MINAS DE MOROCOCHA [197 rows x 5 columns]
#d. Guardar la base de datos en formato csv en la carpeta data. (Use el siguiente nombre Base_cleaned_WG(numero de grupo) junin_data2 =