In [151]:
%matplotlib inline
import pandas as pd
import matplotlib.pyplot as plt
from numpy import nan
plt.style.use('ggplot')

In [ ]:


In [152]:
from IPython.core.display import HTML
css = open('style-table.css').read() + open('style-notebook.css').read()
HTML('<style>{}</style>'.format(css))


Out[152]:

In [ ]:


In [12]:
# Carpeta Base de Datos Faltantes _ X
# Carga de datos
## Por el momento todos los archivos no se encuentran disponibles para descargar

In [13]:
#Cargar archivo 1 (DISCO2-TR_EXP_ALUMNO_CONTROL.txt)
#Intenté estrategia whitespace pero hay columnas vacías y campos con espacios intermedios (falta1 y falta2)

In [14]:
faltante1 = pd.read_csv("/Users/luis/Desktop/CEMABE/BDfaltantes_X/DISCO2-TR_EXP_ALUMNO_CONTROL.txt", sep='\t', header=0, encoding='latin-1', low_memory=False)
faltante1.head()


Out[14]:
CLAVE_CT ID_ALUMNO ENT MUN LOC AGEB MZA NIVEL MODALIDAD TURNO NIVEL_CAM GRADO GRUPO SEXO FECHA_NAC ENT_NAC PAIS_NAC_CVE PASE_LISTA ID_SEP_ACCION C_CUESTIONARIO
0 01DES0009G2 10009056 1 1 1 835 15 4 1 2 NaN 2 I H 29/08/2000 AGUASCALIENTES NaN 10 1 3
1 01DES0009G2 10008394 1 1 1 835 15 4 1 2 NaN 2 J M 08/04/2000 AGUASCALIENTES NaN 10 1 3
2 01DES0009G2 10008400 1 1 1 835 15 4 1 2 NaN 2 K M 20/10/2000 AGUASCALIENTES NaN 10 1 3
3 01DES0009G2 10008403 1 1 1 835 15 4 1 2 NaN 2 I M 22/09/1999 AGUASCALIENTES NaN 10 1 3
4 01DES0009G2 10008393 1 1 1 835 15 4 1 2 NaN 1 L M 14/05/2001 AGUASCALIENTES NaN 10 1 3

In [15]:
faltante2 = pd.read_csv("/Users/luis/Desktop/CEMABE/BDfaltantes_X/DISCO2-TR_EXP_CUES_CONAFE_ALUMNO.txt", header=0, encoding='latin-1', sep='\t', low_memory=False)
faltante2.head()


Out[15]:
ENT MUN LOC AGEB MZA CLAVE_CT ID_ALUMNO NIVEL MODALIDAD TURNO ... P16_3D P16_3E P16_4 P16_5A P16_5B P16_5C P16_6A P16_6B P16_7 P16_8
0 12 56 46 259 1 12KJN0113Y1 120810379 2 6 1 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
1 12 56 46 259 1 12KJN0113Y1 120810380 2 6 1 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2 12 56 46 259 1 12KJN0113Y1 120810381 2 6 1 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
3 12 56 46 259 1 12KJN0113Y1 120810382 2 6 1 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
4 12 56 46 259 1 12KJN0113Y1 120810383 2 6 1 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN

5 rows × 70 columns


In [16]:
faltante3 = pd.read_csv("/Users/luis/Desktop/CEMABE/BDfaltantes_X/DISCO3-TR_EXP_CUES_ALUMNO.txt", sep='|', header=0, encoding='latin-1')
faltante3.head()


Out[16]:
ENT MUN LOC AGEB MZA CLAVE_CT ID_ALUMNO NIVEL MODALIDAD TURNO ... P16_3D P16_3E P16_4 P16_5A P16_5B P16_5C P16_6A P16_6B P16_7 P16_8
0 23 5 1 263A 28 23DST0031M1 230255772 4 2 1 ... 2 4 2 4 6 8 2 4 2 4
1 23 5 1 263A 28 23DST0031M1 230255773 4 2 1 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2 23 5 1 263A 28 23DST0031M1 230255774 4 2 1 ... 2 4 2 4 6 8 2 4 2 4
3 23 5 1 263A 28 23DST0031M1 230255775 4 2 1 ... 2 4 2 4 6 8 2 4 2 4
4 23 5 1 263A 28 23DST0031M1 230255776 4 2 1 ... NaN NaN 2 4 NaN NaN 2 NaN 2 4

5 rows × 70 columns


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [17]:
# Carpeta Centros_trabajo_X
# Carga de datos
## Por el momento todos los archivos no se encuentran disponibles para descargar

In [18]:
centrost1 = pd.read_csv("/Users/luis/Desktop/CEMABE/Centros_trabajo_X/TR_EXP_CENTRAB_CONTROL.txt", header=0, sep='|', encoding='latin-1', index_col=0)
centrost1.head()


Out[18]:
CLAVE_CT ENT MUN LOC AGEB MZA NOMBRECT C_CUESTIONARIO C_ESTATUS_CT NIVEL MODALIDAD TURNO CONTROL
ID_INM
48 01KJN0025Y1 1 5 34 004A 1 PREESCOLAR COMUNITARIO 3 6 2 6 1 1
49 01KJN0258N1 1 5 58 004A 800 PREESCOLAR COMUNITARIO 3 6 2 6 1 1
49 01KPR0025O1 1 5 58 004A 800 CURSO COMUNITARIO 3 6 3 6 1 1
50 01KJN0116P1 1 5 87 0073 800 PREESCOLAR COMUNITARIO 3 6 2 6 1 1
51 01KJN0024Z1 1 5 248 004A 6 PREESCOLAR COMUNITARIO 3 6 2 6 1 1

In [19]:
centrost2 = pd.read_csv("/Users/luis/Desktop/CEMABE/Centros_trabajo_X/TR_EXP_CUES_CENTRAB.txt", header=0, sep='|', encoding='latin-1')
centrost2.head()


Out[19]:
ENT MUN LOC AGEB MZA ID_INM CLAVE_CT NIVEL MODALIDAD TURNO ... P298A P298B P298C P299A P299B P300A P300B P311 P312 P313
0 1 1 1 2723 19 523 01DPR0026D1 3 1 1 ... 4499774570 NaN NaN sigloxx1@outlook.com NaN NaN 1 AGUASCALIENTES AGUASCALIENTES AGUASCALIENTES
1 1 1 1 3825 16 524 01DJN0402Z2 2 1 2 ... NaN NaN 1 NaN 1 NaN 1 AGUASCALIENTES AGUASCALIENTES AGUASCALIENTES
2 1 1 1 3825 16 524 01DJN0400B1 2 1 1 ... 4499294036 NaN NaN NaN 1 NaN 1 AGUASCALIENTES AGUASCALIENTES AGUASCALIENTES
3 1 1 1 3825 16 525 01DPR0703M2 3 1 2 ... 4492931467 NaN NaN temachtiani_tv@hotmail.com NaN NaN 1 AGUASCALIENTES AGUASCALIENTES AGUASCALIENTES
4 1 1 1 3825 16 525 01DPR0688K1 3 1 1 ... 4492930501 NaN NaN temachtianitm@gmail.com NaN NaN 1 AGUASCALIENTES AGUASCALIENTES AGUASCALIENTES

5 rows × 189 columns


In [ ]:


In [20]:
centrost3 = pd.read_csv("/Users/luis/Desktop/CEMABE/Centros_trabajo_X/TR_EXP_CUES_CONAFE_INM_CT_LST.txt", header=0, sep='|', encoding='latin-1')
centrost3.head()


Out[20]:
ID_INM CLAVE_CT PA PB PC1 PC2 PC3 PC4 PD PE ... PF2 PF3 PF4 PF5 PF6 PF7 PF8 PG1 PG2 PG3
0 165 01KJN0001O1 01KJN0001O LOS CUERVOS 1 NaN NaN NaN 1 2 ... 0 13 0 99 99 99 99 22 999 999
1 54 01KJN0002N1 01KJN0002N PREESCOLAR COMUNITARIO 1 NaN NaN NaN 1 9 ... 99 99 99 99 99 99 99 22 999 1
2 61 01KJN0004L1 01KJN0004L PREESCOLAR COMUNITARIO 1 NaN NaN NaN 1 2 ... 0 13 30 99 99 99 99 16 999 1
3 104 01KJN0010W1 01KJN0010W AMAPOLAS DEL RIO 1 NaN NaN NaN 1 2 ... 0 13 30 99 99 99 99 19 999 2
4 1 01KJN0015R1 01KJN0015R PREESCOLAR COMUNITARIO 1 NaN NaN NaN 1 2 ... 0 13 30 99 99 99 99 11 0 999

5 rows × 21 columns


In [ ]:


In [21]:
centrost4 = pd.read_csv("/Users/luis/Desktop/CEMABE/Centros_trabajo_X/TR_EXP_REL_GRADOS_GRUPOS_CT.txt", header=0, sep='|', encoding='latin-1')
centrost4.head()


Out[21]:
CLAVE_CT GRADO GRUPO MULTIGRADO
0 01DPR0021I2 3 A 0
1 01DPR0022H2 5 A 0
2 01DPR0022H2 6 A 0
3 01DPR0022H2 4 A 0
4 01DPR0022H2 3 A 0

In [ ]:


In [22]:
# Carpeta Inmueble (3 archivos)
# Carga de datos
## Por el momento todos los archivos no se encuentran disponibles para descargar

In [ ]:


In [23]:
inmueble1 = pd.read_csv("/Users/luis/Desktop/CEMABE/Inmueble/TR_EXP_CUES_INMUEBLE.txt", header=0, sep='|', encoding='latin-1')
inmueble1.head()


Out[23]:
ENT MUN LOC AGEB MZA ID_INM P2A P2B P3 P4A ... P136 P137 P138 P139 P140 P141 P142 P143 P144 P145
0 2 4 1 2876 23 1914 1 NaN 2 CALLE ... 1 1 1 1 2 1 2 2 1 2
1 2 4 1 2880 103 1915 1 NaN 2 AVENIDA ... 2 1 1 1 1 2 2 2 1 1
2 2 4 1 3677 5 1916 1 NaN 2 AVENIDA ... 2 2 1 1 2 2 3 2 1 2
3 2 4 1 3677 9 1917 1 NaN 2 CALLE ... 1 1 1 1 1 1 2 2 2 2
4 2 4 1 3677 23 1918 7 NaN 2 CALLE ... 1 1 1 1 2 2 2 2 1 1

5 rows × 159 columns


In [ ]:


In [24]:
inmueble2 = pd.read_csv("/Users/luis/Desktop/CEMABE/Inmueble/TR_EXP_INMUEBLE_CONTROL.txt", header=0, sep='|', encoding='latin-1', low_memory=False)
inmueble2.head()


Out[24]:
ID_INM ENT_CARGA MUN_CARGA LOC_CARGA AGEB_CARGA MZA_CARGA LONGITUD_CARGA LATITUD_CARGA ALTITUD_CARGA DOMICILIO_CARGA ... Y NOMVIAL NUMEXT1 NEXTALF1 NUMINT NUMINTALF ENTRECA YCALLE DESCRUBIC C_CUESTIONARIO
0 209238 15 109 25 0188 24 -99.096663 19.682048 .000 CALLE CANCER ... 856924.48508 Cancer 75 NaN NaN NaN Sirio Prados del Centro NaN 3
1 209239 15 109 25 181A 20 -99.104237 19.683822 .000 AVENIDA ARPIAS ... 856799.24477 De Recursos Hidraulicos NaN SN NaN NaN Gorgona De las Arpias NaN 3
2 209240 15 109 68 0667 99 -99.137709 19.620886 .000 CALLE BENITO JUAREZ ... 849884.36876 Benito Juarez 76 NaN NaN NaN Benito Juarez Ninguno NaN 3
3 209241 15 109 68 0864 11 -99.138013 19.632750 2253 CALLE FUENTE DE QUIJOTE ... 851143.70765 Fuente de Quijote 14 NaN NaN NaN F. Bella F. de Cibeles NaN 3
4 209242 15 109 68 0864 12 -99.138611 19.632500 .000 AVENIDA REAL DEL BOSQUE ... 849628.41869 Real del Bosque NaN SN NaN NaN Bosque de Araucarias Bosque de Biclamores NaN 3

5 rows × 32 columns


In [25]:
inmueble3 = pd.read_csv("/Users/luis/Desktop/CEMABE/Inmueble/TR_EXP_CUES_CONAFE_INM_CT.txt", header=0, sep='|', encoding='latin-1', low_memory=False, error_bad_lines=False, warn_bad_lines=True)
inmueble3.head()


b'Skipping line 965: expected 84 fields, saw 85\nSkipping line 2720: expected 84 fields, saw 85\nSkipping line 4799: expected 84 fields, saw 85\nSkipping line 24241: expected 84 fields, saw 85\n'
Out[25]:
ENT MUN LOC AGEB MZA ID_INM P2 P3 P4 P5 ... P56 P57A P57B P57C P57D P57E P57F P58A P58B P59
0 1 1 597 1937 2 119 1 1 1 1 ... 2 LOS CUERVOS 6 EL GUARDA AGUASCALIENTES AGUASCALIENTES 20369 JALISCO OJUELOS 1
1 1 1 605 1937 800 121 1 1 1 1 ... 2 NaN NaN NaN AGUASCALIENTES AGUASCALIENTES 20384 AGUASCALIENTES AGUASCALIENTES 2
2 1 1 410 1231 6 1 1 1 1 1 ... 2 CUBA S/N SAN PEDRO CIENEGUILLA AGUASCALIENTES AGUASCALIENTES 20377 AGUASCALIENTE AGUASCALIENTES 1
3 1 1 422 1068 7 2 1 1 2 1 ... 1 CALLE XOCONOXTLE CARRETERA VILLA HIDALGO KM 3 20317 SANTA CRUZ DE LA PRRESA AGUASCALIENTES AGUASCALIENTES 20317 AGUASCALIENTES AGUASCALIENTES 1
4 1 1 466 1250 800 4 1 1 9 1 ... 9 NaN NaN EL TURICATE AGUASCALIENTES AGUASCALIENTE 20287 AGUASCALIENTES AGUASCALIENTES 2

5 rows × 84 columns


In [ ]:


In [26]:
# Carpeta personal
# Cargar datos

In [27]:
personal1 = pd.read_csv("/Users/luis/Desktop/CEMABE/Personal/TR_EXP_ACTIVIDADES_ACADEMICOS.txt", header=0, sep='|', encoding='latin-1')
personal1.head()


Out[27]:
CLAVE_CT CURP ID_PERSONA ENT MUN LOC AGEB MZA NIVEL MODALIDAD TURNO ID_SEP_ACTIVIDAD ESPECIFIQUE
0 09DPR1397U1 GAMC780930MDFRDR06 563996 9 5 1 2907 3 3 1 1 12 NaN
1 09DPR1397U1 GIOM500119MSPRRR03 604899 9 5 1 2907 3 3 1 1 1 NaN
2 09DPR1397U1 GOTG630104HGRNRN05 661562 9 5 1 2907 3 3 1 1 12 NaN
3 09DPR1397U1 HEBG820920HHGRRV04 709072 9 5 1 2907 3 3 1 1 1 NaN
4 09DPR1397U1 HEMN780927MDFRNL03 748238 9 5 1 2907 3 3 1 1 1 NaN

In [ ]:


In [28]:
personal2 = pd.read_csv("/Users/luis/Desktop/CEMABE/Personal/TR_EXP_CUES_CONAFE_PERSONAL.txt", header=0, sep='|', encoding='latin-1')
personal2.head()


/Users/luis/anaconda/lib/python3.4/site-packages/IPython/core/interactiveshell.py:2902: DtypeWarning: Columns (30) have mixed types. Specify dtype option on import or set low_memory=False.
  interactivity=interactivity, compiler=compiler, result=result)
Out[28]:
ENT MUN LOC AGEB MZA CLAVE_CT ID_PERSONA NIVEL MODALIDAD TURNO ... P32H P33A P33B P33C P33D P33E P33F P34 P35 P36
0 1 6 183 0013 7 01KJN0118N1 600815 2 6 1 ... NaN NaN 2 NaN NaN NaN NaN 3 2 2
1 1 1 128 1759 7 01KJN0119M1 106584 2 6 1 ... NaN 1 1 NaN NaN NaN NaN 3 2 2
2 1 1 128 1759 7 01KJN0119M1 742838 2 6 1 ... NaN NaN 1 NaN NaN NaN NaN 3 2 2
3 1 10 21 0069 8 01KJN0124Y1 1067488 2 6 1 ... NaN 3 1 NaN NaN NaN NaN 3 2 2
4 1 1 569 1763 800 01KJN0125X1 1101053 2 6 1 ... NaN NaN 1 NaN NaN NaN NaN 2 2 2

5 rows × 145 columns


In [ ]:


In [29]:
personal3 = pd.read_csv("/Users/luis/Desktop/CEMABE/Personal/TR_EXP_CUES_PERSONAL_PLAZA.txt", header=0, sep='|', encoding='latin-1', error_bad_lines=False, warn_bad_lines=True)
personal3.head()


b'Skipping line 736828: expected 14 fields, saw 15\n'
b'Skipping line 1754835: expected 14 fields, saw 15\n'
b'Skipping line 1973770: expected 14 fields, saw 15\n'
Out[29]:
CLAVE_CT CURP ID_PERSONA NIVEL MODALIDAD TURNO ID_CUES_PERSONAL_PLAZA PA PB PC PD PE PF PG
0 08DES0003F2 CAEJ560713HCHZSV09 226559 4 1 2 957352 076313E0363030000187 1 2 3 1 DOCENTE E0363
1 08DES0003F2 CAEJ560713HCHZSV09 226559 4 1 2 957354 076313E0363030000210 1 2 3 1 DOCENTE E0363
2 08DES0003F2 CAEJ560713HCHZSV09 226559 4 1 2 957348 076313E0363020080071 1 2 2 1 DOCENTE E0363
3 08DES0003F2 CAEJ560713HCHZSV09 226559 4 1 2 957346 076313E0363010000223 1 2 1 1 DOCENTE E0363
4 08DES0003F2 CAEJ560713HCHZSV09 226559 4 1 2 957356 076313E0363030000327 1 2 3 1 DOCENTE E0363

In [ ]:


In [30]:
personal4 = pd.read_csv("/Users/luis/Desktop/CEMABE/Personal/TR_EXP_CUES_PERSONAL.txt", header=0, sep='|', encoding='latin-1', error_bad_lines=False, warn_bad_lines=True)
personal4.head()


b'Skipping line 1801131: expected 197 fields, saw 198\n'
/Users/luis/anaconda/lib/python3.4/site-packages/IPython/core/interactiveshell.py:2902: DtypeWarning: Columns (167,169,172,175,177,178,179,180,181,182,184,185,186,187,188,189,190,191,192) have mixed types. Specify dtype option on import or set low_memory=False.
  interactivity=interactivity, compiler=compiler, result=result)
Out[30]:
ENT MUN LOC AGEB MZA CLAVE_CT CURP ID_PERSONA NIVEL MODALIDAD ... P42_3BC P42_3C P42_3CC P42_3D P42_3E P42_3OT P43A P43B P44 P45
0 1 1 1 2634 1 01DPR0021I2 CARA630911HASSDM02 275244 3 1 ... NaN NaN NaN NaN NaN NaN 1 NaN 2 NaN
1 1 1 1 2634 1 01DPR0021I2 FOVR680704HASLSF06 515000 3 1 ... NaN NaN NaN NaN NaN NaN 1 NaN NaN NaN
2 1 1 1 2634 1 01DPR0021I2 HEBF581003HASRRR06 708850 3 1 ... NaN NaN NaN NaN NaN NaN 1 NaN NaN NaN
3 1 1 1 2634 1 01DPR0021I2 LOGJ760307HASPRR08 882897 3 1 ... NaN NaN NaN NaN NaN NaN 2 NaN NaN NaN
4 1 1 1 2634 1 01DPR0021I2 MANS580920MASRJL09 981735 3 1 ... NaN NaN NaN NaN NaN NaN 1 NaN NaN 1

5 rows × 197 columns


In [ ]:


In [31]:
personal5 = pd.read_csv("/Users/luis/Desktop/CEMABE/Personal/TR_EXP_MATERIAS_MAESTROS.txt", header=0, sep='|', encoding='latin-1', error_bad_lines=False, warn_bad_lines=True)
personal5.head()


/Users/luis/anaconda/lib/python3.4/site-packages/IPython/core/interactiveshell.py:2902: DtypeWarning: Columns (11) have mixed types. Specify dtype option on import or set low_memory=False.
  interactivity=interactivity, compiler=compiler, result=result)
Out[31]:
CLAVE_CT CURP ID_PERSONA ENT MUN LOC AGEB MZA NIVEL MODALIDAD TURNO GRADO GRUPO MATERIA_CVE1 MATERIA_CVE2 MATERIA
0 15KPR0409W1 NaN 667073 15 1 96 0184 1 3 6 1 3 A 3388800000 30300000 EXPLORACION DE LA NATURALEZA Y SOCIEDAD
1 15KPR0409W1 NaN 667073 15 1 96 0184 1 3 6 1 3 A 3388800000 30700000 HISTORIA
2 15KPR0409W1 NaN 667073 15 1 96 0184 1 3 6 1 3 A 3340300000 40300000 FORMACION CIVICA Y ETICA
3 15KPR0409W1 NaN 667073 15 1 96 0184 1 3 6 1 3 A 3340100000 40100000 EDUCACION FISICA
4 15KPR0409W1 NaN 667073 15 1 96 0184 1 3 6 1 3 A 3310300000 10300000 ESPAÑOL

In [ ]:


In [32]:
personal6 = pd.read_csv("/Users/luis/Desktop/CEMABE/Personal/TR_EXP_PERSONAL_CONTROL.txt", header=0, sep='|', encoding='latin-1', error_bad_lines=False, warn_bad_lines=True)
personal6.head()


Out[32]:
CLAVE_CT CURP ID_PERSONA ENT MUN LOC AGEB MZA NIVEL MODALIDAD ... FECHA_NAC ENT_NAC PAIS_NAC_CVE PASE_LISTA ID_SEP_ACCION PLAZA NUM_PLAZAS IMPARTE_CLASES HORAS C_CUESTIONARIO
0 18DST0032Z1 AEBC621005MNTMRL07 51043 18 17 106 0830 79 4 2 ... 05/10/1962 NAYARIT NaN 11 1 0 1 2 NaN 3
1 09PES0287F1 NaN 51044 9 8 1 0283 15 4 1 ... 11/03/1963 DISTRITO FEDERAL NaN 11 2 1 NaN 0 15 3
2 25FJZ0006M4 AEBC630428MSLMRR06 51045 25 6 1 0131 35 9 NaN ... 28/04/1963 SINALOA NaN 53 1 NaN NaN 0 NaN 1
3 18ADG0004K1 AEBC630816MNTMTC08 51046 18 17 1 1275 17 9 NaN ... 16/08/1963 NAYARIT NaN 34 1 0 1 2 NaN 3
4 30EJN1114I1 NaN 51047 30 44 120 0788 6 2 1 ... 21/11/1963 OAXACA NaN 11 1 0 1 2 NaN 3

5 rows × 26 columns


In [ ]:


In [33]:
personal7 = pd.read_csv("/Users/luis/Desktop/CEMABE/Personal/TR_EXP_PLAZAS.txt", header=0, sep='|', encoding='latin-1', error_bad_lines=False, warn_bad_lines=True)
personal7.head()


Out[33]:
CLAVE_CT CURP ID_PERSONA ENT MUN LOC AGEB MZA NIVEL MODALIDAD TURNO PLAZA ID_SEP_VERIFICACION_ACTIVIDAD ID_SEP_ACCION
0 31DIN2078L4 AXBL750311MCCCLC04 130529 31 101 16 0155 14 9 NaN 4 079829 E146100.0310086 2 1
1 31DIN2079K4 IXMD780924MYNCNY08 797759 31 94 10 0055 11 9 NaN 1 079829 E146100.0310016 2 1
2 31DIN2080Z4 SAKI650210MYNNXR03 1535276 31 89 7 0106 1 9 NaN 4 079829 E146100.0310002 2 1
3 31DIN2081Z4 COCE591030MYNRNV01 329515 31 17 17 008A 1 9 NaN 4 079829 E146100.0310087 2 1
4 31DIN2082Y4 PESM720203MYNCBR00 1280336 31 2 11 0053 11 9 NaN 4 079829 E146100.0310006 2 1

In [ ]:
#Transformaciones
##Diccionarios

sustituciones = {
    'P3': {1: 11, 2: 8, 3: 3, 4:0, 5: 0},
    'P11': {0: 1, 1: 1}, #.get(key, 0) #>1
    'P13A': {1: 1.5, 2: 1, 3: 1, 4: 0, 5: 0},
    'P14': {1: 3, 2: 2, 3: 0, 4: 0, 5: 0, 6: 0},
    'P15': {1: 3, 2: 2, 3: 2, 4: 0, 5: 0, 6: 0},
    'P16': {1: 3, 2: 2, 3: 0},
    'P17A': {1: 3, 2: 2, 3: 2, 4: 0, 5: 1, 6: 0},
    'P18A': {1: 3, 2: 2, 3: 2, 4: 1, 5: 0},
    'P19': {1: 1, 2: 0},
    'P20': {1: 3, 2:0},
    'P21': {1: 3, 2:0},
    'P22': {1: 3, 2:0},
    'P23': {1: 5.5, 2:0},
    'P24': {1: 5.5, 2:0},
    'P25': {0: 0, 1: 0.5, 2: 1,}#.get(key, 1) #2+: 1
    'P26': {0: 0, 1: 1}#.get(key, 0) #1+: 1
    'P27': {0: 0, 1: 1}#.get(key, 0) #1+: 1
    'P28': {0: 0.3, 1: 0}#.get(key, 0) #2+: 0
    'P29': {0: 0.3, 1: 0}#.get(key, 0) #2+: 0
    'P30': {0: 0.3, 1: 0}#.get(key, 0) #2+: 0
    'P31': {0: 0.3, 1: 0}#.get(key, 0) #2+: 0
    'P32': {0: 0.3, 1: 0}#.get(key, 0) #2+: 0
    'P33': {0: 0.5, 1: 0}#.get(key, 0) #2+: 0
    'P34': {0: 0, 1: 1}#.get(key, 0) #1+: 1
}

##Funciones
p3 = lambda n: p3_d.get(n)
p11 = lambda n: p11_d.get(n,0)
p12 = lambda n: p12_d.get(n)
p13A
funciones = [p11,p12,p13A, None, p]
#Columnas
##Metatransform
map(lambda x,y:x(y), functions, values)

In [153]:
df = pd.read_excel('INMUEBLES.xlsx')

In [11]:
len(df[df['P12']>1]['P12'])


Out[11]:
40416

In [82]:
df2=df[df['P3']<6]
len(df2['P3'])


Out[82]:
151096

In [94]:
df2.ix[(df['P22']==3) & (df['P20']==3),'P20']=0


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s

In [69]:
df2[(df['P22']==1) & (df['P20']==1)] #Estas respuestas no deberían tener sentido según el archivo de ponderaciones


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)
Out[69]:
ENT MUN LOC AGEB MZA ID_INM P2A P2B P3 P4A ... P136 P137 P138 P139 P140 P141 P142 P143 P144 P145
194 2 4 1 0210 30 1802 1 NaN 2 CALLE ... 1 1 1 1 1 1 1 2 1 1
281 2 4 187 5828 22 2034 1 NaN 2 AVENIDA ... 2 2 1 1 1 1 2 2 1 1
319 2 4 1 3766 50 1947 1 NaN 1 CALLE ... 9 9 9 9 9 3 1 1 2 2
898 5 30 1 2668 23 8942 1 NaN 1 CALLE ... 1 1 1 2 2 1 3 2 1 1
1087 5 33 59 0860 22 10588 2 NaN 1 EJIDO PROGRESO ... 2 2 2 2 2 3 3 3 2 1
1152 5 35 1 1223 1 9320 1 NaN 1 CALLE ... 2 2 1 2 1 3 2 2 1 1
1409 5 7 14 120A 25 10335 1 NaN 2 SIN NOMBRE ... 1 2 2 2 2 3 3 3 2 3
1850 3 8 54 0337 25 5716 7 NaN 2 CALLE ... 1 1 1 1 1 3 2 2 1 2
1907 3 8 54 0939 7 5721 8 MAESTRA 2 CALLE ... 1 1 1 1 2 2 2 2 1 1
1970 4 6 3 0021 22 6594 2 NaN 1 CALLE ... 2 2 1 1 1 3 1 2 2 1
2030 5 35 1 3944 19 9656 7 NaN 2 CALLE ... 1 2 1 2 1 3 1 2 2 2
2032 5 35 1 3959 3 9658 1 NaN 2 CALLE ... 1 2 1 2 2 3 2 2 1 1
2184 4 2 1 1603 21 6285 2 NaN 1 CALLE ... 1 2 2 2 2 2 1 1 2 1
2185 4 2 1 1603 21 6286 1 NaN 1 CALLE ... 1 1 1 1 1 3 1 1 1 2
2202 3 3 1 1856 3 5435 1 NaN 2 CALLE ... 1 1 1 1 1 3 2 2 1 2
2214 4 1 1 0383 14 6023 2 NaN 1 CALLE ... 2 2 2 2 1 3 2 2 1 1
2241 5 17 1 0509 3 10704 1 NaN 1 CALLE ... 2 2 2 2 2 2 3 2 1 1
2267 4 1 1 0383 20 6024 1 NaN 1 CALLE ... 1 1 1 1 1 3 2 2 1 1
2296 5 35 1 2096 27 9599 1 NaN 1 CERRADA ... 1 1 1 2 1 3 1 2 2 1
2366 5 38 41 0513 8 9903 8 DIRECTOR COMISIONADO CON GRUPO 1 NaN ... 9 9 9 9 9 3 3 2 1 2
2409 3 8 54 0869 17 5689 1 NaN 1 CALLE ... 2 2 2 2 1 2 2 1 1 2
2423 5 9 21 0418 15 10432 8 EDUCADORA ENCARGADA 1 SIN NOMBRE ... 2 2 1 2 1 2 2 2 2 1
2433 5 28 1 106A 10 10187 2 NaN 1 CARRETERA ... 2 2 1 2 1 2 2 2 1 1
2453 5 2 1 1788 9 9683 1 NaN 1 CALLE ... 1 1 1 1 1 2 1 2 1 1
2539 4 2 1 136A 6 6316 1 NaN 1 CALLE ... 1 1 1 1 1 3 1 2 1 2
2540 4 4 1 1947 37 6620 1 NaN 1 CALLE ... 1 2 1 2 1 3 1 2 1 1
2542 4 4 24 1152 55 6622 1 NaN 1 CALLE ... 2 2 2 2 1 3 2 2 2 2
2548 4 4 82 110A 7 6628 1 NaN 1 CALLE ... 1 1 1 1 1 3 1 1 1 1
2705 5 9 28 0988 17 10437 8 EDUCADORA FRENTE AGRUPO 1 NINGUNO ... 2 2 1 2 1 2 1 2 2 1
2726 5 23 42 2470 13 10205 1 NaN 1 CAMINO ... 2 2 1 2 2 2 1 2 1 2
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
163208 30 174 123 0161 14 187519 1 NaN 1 CALLE ... 2 2 1 2 2 2 2 2 1 1
163260 30 32 79 0043 1 187759 1 NaN 1 LOCALIDAD ... 2 2 2 2 2 3 3 3 3 3
163569 30 143 324 0042 1 186120 1 NaN 1 CALLE ... 2 2 2 2 2 2 2 2 2 1
163769 30 169 31 0087 2 186661 2 NaN 1 CALLE ... 2 1 1 2 2 3 1 1 2 1
163833 30 169 64 0087 3 186671 1 NaN 1 NaN ... 2 1 2 1 1 3 2 2 1 1
163941 30 70 4 0059 11 189451 1 NaN 2 INDEPENDENCIA ... 2 2 2 2 2 3 2 2 2 2
163975 30 210 37 0244 8 189543 1 NaN 1 CALLE ... 2 2 2 2 1 2 2 2 2 2
164395 30 145 10 0013 6 188650 1 NaN 1 CALLE ... 2 1 2 2 2 2 2 2 1 2
164441 31 96 69 0562 6 193372 2 NaN 1 CALLE ... 1 2 1 2 1 3 2 1 2 2
164838 30 108 1 1130 7 188973 1 NaN 2 CALLE ... 2 2 2 2 2 2 2 2 2 2
164852 30 199 11 0014 1 188539 1 NaN 1 CALLE ... 2 2 1 2 2 3 2 2 1 2
164900 30 210 22 0244 5 189539 1 NaN 1 CALLE ... 2 1 1 2 2 2 2 3 1 2
165057 30 142 1 0238 3 188716 1 NaN 2 AVENIDA ... 2 1 1 2 1 3 3 3 2 1
165062 30 108 1 1198 16 188996 1 NaN 1 CALLE ... 1 1 1 1 1 2 1 2 1 1
165092 31 59 1 0520 15 190797 7 NaN 2 CALLE 27 ... 2 2 1 2 2 3 2 2 1 1
165094 31 59 1 0535 13 190799 1 NaN 2 CALLE 35 ... 1 2 1 1 1 2 1 1 1 1
165145 31 50 1 5009 19 191245 1 NaN 1 CALLE ... 1 1 1 2 1 3 2 2 1 1
165332 31 50 1 2413 7 191221 1 NaN 1 CALLE ... 1 1 1 1 1 3 2 2 1 2
165393 30 39 21 1428 27 189892 1 NaN 2 CALLE ... 1 2 2 2 2 2 2 2 1 1
165518 31 50 1 5066 27 191188 1 NaN 1 CALLE ... 1 1 1 1 1 2 2 2 1 9
165525 31 50 1 2451 22 191195 8 DIRECTOR ADMINISTRATIVO 1 CALLE ... 1 1 1 1 2 3 2 2 1 1
165529 31 50 1 2470 9 191199 8 COORDINADOR TECNOLOGICO 1 CARRETERA ... 1 1 1 2 2 3 1 1 1 2
165581 30 39 40 0256 7 190064 1 NaN 1 CALLE ... 1 1 1 1 1 2 1 1 2 2
165614 31 50 1 2714 29 191116 1 NaN 1 CALLE ... 1 1 1 1 1 3 2 2 1 1
165616 31 50 1 5865 22 191119 1 NaN 2 CALLE ... 1 1 1 1 1 2 2 2 1 2
165884 31 50 1 2220 16 191108 1 NaN 1 CALLE ... 1 1 1 1 2 2 1 1 2 2
165885 31 50 1 2235 6 191110 7 NaN 2 AVENIDA 7 ... 1 1 1 1 1 2 2 2 1 1
165953 31 59 1 0499 10 190789 1 NaN 2 CALLE ... 1 2 1 1 1 1 2 2 1 2
166026 31 50 1 1487 17 191263 8 SECRETARIA ADMINISTRATIVA 1 CALLE ... 1 1 1 1 1 3 1 2 1 2
166031 30 61 17 0223 1 190173 1 NaN 1 CARRETERA ... 2 2 1 2 2 2 1 1 1 1

2877 rows × 159 columns


In [14]:
#Transformaciones
##Diccionarios
p3_d = {1:,2:,3:,4:,5:}


Out[14]:
15042

In [8]:
df2[df2['P12']>2]


Out[8]:
ENT MUN LOC AGEB MZA ID_INM P2A P2B P3 P4A ... P136 P137 P138 P139 P140 P141 P142 P143 P144 P145
39 1 5 1 050A 1 1520 2 NaN 1 CALLE ... 2 2 1 2 1 3 2 2 1 1
70 2 4 1 1473 43 1678 1 NaN 2 AVENIDA ... 1 1 1 1 1 2 2 2 1 1
93 2 4 1 3412 10 1872 1 NaN 1 AVENIDA ... 2 2 1 1 1 2 2 2 1 2
488 2 5 1 0468 5 2108 1 NaN 2 CALLE ... 1 1 1 1 1 1 2 2 1 1
494 2 4 1349 5029 32 2114 1 NaN 1 CALLE ... 2 1 1 2 1 2 1 2 2 2
529 2 4 1 1350 2 2300 1 NaN 2 CALLE ... 1 1 1 1 1 1 2 2 1 2
570 2 4 1 3234 30 2210 1 NaN 2 AVENIDA ... 1 1 1 1 1 2 2 2 1 1
677 5 35 1 1312 7 9230 1 NaN 1 CALLE ... 1 2 2 2 1 2 2 2 1 2
678 5 35 1 4406 17 9231 2 NaN 2 CALLE ... 2 2 2 2 2 2 2 2 2 2
690 5 35 150 2147 800 9244 1 NaN 1 CARRETERA ... 2 2 1 2 1 3 1 2 1 1
741 5 33 1 0998 47 10660 1 NaN 2 AVENIDA ... 2 2 1 2 2 2 2 2 2 1
754 5 35 1 2024 2 8330 3 NaN 2 AVENIDA ... 1 1 1 2 1 3 2 2 1 1
763 5 35 1 3906 3 8339 1 NaN 2 CALLE ... 1 1 1 1 1 3 2 2 2 2
784 5 30 1 0074 64 8990 1 NaN 2 CALLE ... 1 1 1 1 1 2 2 2 1 1
794 5 30 1 0178 28 9000 1 NaN 2 CALLE ... 1 1 1 1 1 3 2 2 1 2
1032 5 35 1 0263 54 9498 1 NaN 1 CALLE ... 1 1 1 1 2 3 2 2 1 1
1036 5 35 1 1524 24 9502 5 NaN 1 CALLE ... 2 2 1 1 1 3 2 2 1 2
1037 5 35 1 1524 24 9503 1 NaN 1 CALLE ... 2 2 1 1 1 3 2 2 1 2
1066 5 30 1 4630 21 8713 1 NaN 1 CALLE ... 1 1 1 1 1 2 1 2 1 1
1118 5 25 1 0765 41 10038 1 NaN 2 LIBRAMIENTO ... 1 1 1 1 1 3 2 2 1 1
1128 5 33 104 1568 13 10319 1 NaN 2 SIN NOMBRE ... 2 2 2 2 2 3 2 2 2 2
1305 5 35 1 1473 4 9509 1 NaN 2 CALLE ... 2 2 1 2 2 3 2 2 1 2
1312 5 35 1 3770 49 9257 1 NaN 2 CERRADA ... 1 1 1 2 2 2 2 2 3 1
1319 5 35 1 3978 4 9265 2 NaN 2 NaN ... 2 2 2 2 2 2 2 2 2 2
1320 5 35 1 4548 1 9266 1 NaN 3 JAIME TORRES BODED ... 2 2 2 2 2 2 2 2 1 1
1396 5 30 1 2920 40 8666 5 NaN 2 CALLE ... 1 1 1 1 1 3 3 2 1 2
1450 5 35 1 0051 60 9215 1 NaN 2 CALLE ... 1 1 1 1 1 2 2 2 1 2
1568 5 30 1 4645 32 8735 1 NaN 1 BOULEVARD ... 1 1 1 1 1 3 2 2 1 2
1599 5 35 1 1204 44 9280 1 NaN 2 CALLE ... 1 1 1 1 1 2 1 2 1 2
1635 5 30 1 0055 27 8752 5 NaN 2 BOULEVARD ... 1 1 1 1 1 3 2 2 1 2
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
165947 31 59 1 0484 1 190783 1 NaN 1 CALLE ... 2 2 1 2 2 3 2 2 1 2
165948 31 59 1 0484 5 190784 1 NaN 1 CALLE ... 2 1 1 2 2 3 2 2 1 1
165949 31 59 1 0484 13 190785 6 NaN 1 CALLE ... 1 1 1 2 2 3 2 2 1 1
165953 31 59 1 0499 10 190789 1 NaN 2 CALLE ... 1 2 1 1 1 1 2 2 1 2
165966 30 61 12 005A 800 190159 1 NaN 2 CARRETERA A TECUANAPA ... 1 1 1 1 1 3 2 2 1 1
165968 30 61 33 0030 800 190161 2 NaN 3 CARRETERA ... 2 2 2 2 1 3 2 2 2 1
165970 30 61 64 0030 800 190164 1 NaN 2 CAMINMO ... 2 2 1 1 1 2 3 2 1 2
165971 30 61 378 0030 800 190167 1 NaN 2 CALLE ... 1 1 2 2 2 2 2 2 2 2
165973 30 61 1075 0030 800 190169 1 NaN 2 CARRETERA ... 1 2 1 1 1 2 2 2 1 1
165977 30 210 157 0210 800 189635 1 NaN 2 CALLE ... 2 2 2 2 2 3 2 2 2 2
165979 30 210 14 0085 4 189637 8 DIRECTOR COMISIONADO CON GRUPO 1 CALLE ... 1 1 2 2 2 3 1 2 1 1
165995 30 89 1 0243 37 188457 1 NaN 1 CALLE ... 2 1 2 2 1 3 2 2 2 1
165996 30 89 7 0027 2 188458 1 NaN 1 CALLE ... 2 2 2 2 2 3 1 2 2 1
165998 30 89 14 0027 2 188460 1 NaN 1 CALLE ... 2 2 2 2 1 3 2 2 1 2
166003 30 142 19 0100 2 188743 1 NaN 1 CALLE ... 1 1 2 2 1 2 2 2 1 1
166004 30 142 24 0100 5 188744 8 DIRECTORA COMICIONADA 1 CALLE ... 1 1 2 1 1 2 2 2 1 2
166007 30 142 30 0100 4 188747 8 DIRECTOR COMICIONADO 1 CALLE ... 1 1 2 2 1 2 2 1 2 2
166009 30 142 45 0100 19 188749 8 DIRECTOR COMICIONADO 1 CARRETERA FEDERAL ... 2 1 1 2 1 2 2 2 2 2
166030 30 61 9 005A 800 190172 1 NaN 1 CALLE ... 1 2 1 2 1 3 2 2 1 1
166034 30 61 43 0153 3 190176 1 NaN 1 CARRETERA ... 2 1 1 1 1 2 2 2 1 1
166043 31 52 3 0106 16 190862 8 ENCARGADO DE LA DIRECCION CON GRUPO 1 CALLE ... 2 2 2 2 2 2 1 1 2 2
166044 31 52 3 0106 1 190863 8 DIRECTORA CON GRUPO 1 CALLE ... 2 2 1 2 2 2 2 2 2 2
166058 30 91 30 0063 12 189311 8 MAESTRA DE GRUPO 2 CALLE ... 2 2 2 1 1 3 2 2 2 1
166060 30 91 30 0063 5 189313 1 NaN 2 CALLE ... 2 2 1 2 1 3 2 2 1 2
166074 30 48 1 0128 4 189021 1 NaN 2 CALLE ... 1 2 1 1 1 2 2 2 1 1
166091 30 39 1 1235 32 189792 2 NaN 1 CALLE ... 2 2 1 1 1 3 3 2 1 1
166093 30 39 170 1911 2 189794 1 NaN 3 AVENIDA ... 2 1 2 1 1 3 2 2 1 2
166096 30 39 142 1555 15 189797 1 NaN 1 CALL ... 2 2 1 1 1 2 1 2 1 2
166102 31 52 5 0106 14 190867 3 NaN 1 CALLE ... 2 2 1 2 2 2 1 2 2 2
166103 31 52 24 0110 1 190868 8 MAESTRO FRENTE A GRUPO 1 CALLE ... 2 2 1 2 2 2 1 1 2 2

11059 rows × 159 columns


In [45]:
df2['P11'].replace({0: 1, 1:1, 2:0},inplace=True)


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)

In [84]:
#df2.ix[df2.P12<1, 'P12'] = 3
df2.ix[df2.P12>2, 'P12'] = 3
#df2[df2['P12']<1]['P12']


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s

In [85]:
df2['P12'].replace({1: 1.5, 2: 1, 3: 0},inplace=True)


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)

In [12]:
df2[df2['P13A']>4]


Out[12]:
ENT MUN LOC AGEB MZA ID_INM P2A P2B P3 P4A ... P136 P137 P138 P139 P140 P141 P142 P143 P144 P145
325 2 4 1 0511 53 1953 1 NaN 2 CALLE ... 1 1 1 2 1 3 3 3 2 1
394 2 5 89 0951 19 2131 1 NaN 1 CALLE ... 1 1 1 2 1 2 2 3 1 1
404 2 4 1 0282 13 2272 1 NaN 1 CIRCUITO ... 1 1 1 1 1 1 1 2 1 1
465 2 5 1 0379 23 2084 1 NaN 2 CALLE ... 1 1 1 1 1 2 3 2 1 1
545 2 4 1 1543 23 2316 1 NaN 1 AVENIDA ... 1 1 1 1 1 2 1 2 1 1
574 2 4 1 0117 35 2214 1 NaN 2 AVENIDA ... 2 2 1 1 1 3 2 2 1 1
834 5 33 85 1534 13 10294 1 NaN 1 CALLE ... 2 2 1 2 2 2 1 2 2 2
868 5 35 1 2005 2 9304 8 DIRECTOR CON GRUPO 1 CALLE ... 1 2 1 2 2 3 2 3 2 1
957 5 27 38 1289 2 10388 1 NaN 2 CALLE ... 2 2 2 2 1 2 1 3 2 2
997 5 24 1 2105 1 8415 1 NaN 1 CALLE ... 1 1 1 1 1 3 1 2 1 2
1213 5 24 27 1821 12 8419 1 NaN 1 EJIDO LA CONSTANCIA ... 2 2 1 1 1 3 2 2 1 1
1228 5 12 162 031A 800 10116 8 DIRECTOR COMICIONADO 2 CALLE ... 2 2 2 2 2 3 1 1 1 2
1235 5 27 85 1185 2 10398 1 NaN 2 CAMINO ... 2 2 1 2 2 2 1 2 1 2
1238 5 27 96 126A 800 10401 1 NaN 2 CALLE ... 2 2 2 2 2 2 1 2 2 2
1239 5 27 96 126A 800 10402 1 NaN 2 CAMINO ... 2 2 1 2 1 2 1 2 2 1
1241 5 30 1 0290 45 8959 1 NaN 2 CALLE ... 1 1 1 1 1 3 2 2 1 2
1357 5 30 1 4217 2 9031 1 NaN 1 CARRETERA ... 1 2 2 2 1 3 2 2 1 2
1361 5 30 1 508A 11 9035 1 NaN 1 CALLE ... 9 9 9 9 9 3 2 2 1 1
1401 5 25 1 052A 6 10056 1 NaN 1 AVENIDA ... 1 1 1 1 1 1 2 2 1 1
1412 5 7 22 1106 15 10338 1 NaN 2 CALLE ... 2 2 2 2 2 3 1 1 2 2
1464 5 30 1 0248 46 8970 1 NaN 2 CALLE ... 1 1 1 1 1 3 2 2 1 2
1542 5 33 48 0663 3 10519 1 NaN 1 NaN ... 2 2 1 2 1 3 2 2 1 2
1551 5 33 112 0663 21 10528 8 DIRECTOR COMISIONADO 1 NaN ... 2 2 1 2 2 3 3 2 1 1
1573 5 30 1 1918 32 8741 1 NaN 1 PRIVADA ... 1 2 1 2 2 2 2 2 1 1
1610 5 2 1 2875 17 9756 2 NaN 1 AVENIDA ... 1 1 1 2 1 2 2 2 1 2
1773 4 4 1 1951 21 6655 1 NaN 2 CALLE ... 2 1 1 1 1 2 2 2 1 1
1791 5 28 1 0358 3 10146 2 NaN 2 CALLE ... 2 2 1 2 1 3 2 2 1 1
1809 5 23 30 3303 10 10221 1 NaN 2 EJIDO ... 1 2 2 2 1 3 1 1 2 2
1881 5 33 79 1553 6 10597 2 NaN 1 DOMICILIO CONOCIDO ... 2 2 1 2 2 3 3 3 3 3
2210 4 1 7 0186 24 6019 1 NaN 1 CAALLE ... 2 1 1 1 1 3 1 2 1 2
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
165183 30 61 1020 005A 800 190194 8 MAESTRO FRENTE A GRUPO 1 CARRETERA A XICOTENCATL ... 2 2 1 2 1 3 2 2 1 1
165185 30 61 1117 0223 800 190196 1 NaN 1 CARRETERA ... 1 1 2 2 1 2 1 2 2 2
165224 30 204 1 0020 9 190037 1 NaN 2 CALLE ... 1 1 1 1 1 2 2 2 1 1
165272 30 210 98 0225 17 189603 1 NaN 2 CALLE ... 2 2 2 2 2 3 2 2 1 2
165276 30 210 19 016A 800 189609 1 NaN 2 CALLE ... 2 2 1 2 2 2 2 2 2 2
165277 30 210 21 0136 4 189610 1 NaN 2 CALLE ... 2 1 2 2 1 3 2 2 2 2
165315 30 204 16 0092 1 190113 1 NaN 1 NaN ... 1 1 2 1 1 1 2 2 1 2
165341 30 142 27 012A 2 188768 8 MAESTRA FRENTE A GRUPO 2 CALLE ... 2 1 2 2 1 2 2 2 1 2
165350 30 48 24 0217 21 189058 8 DIRECTOR COMISIONADO CON GRUPO 1 CALLEJON ... 1 1 2 2 1 2 2 2 1 1
165361 30 61 729 0365 14 190353 1 NaN 2 CALLE ... 2 1 2 2 1 3 2 2 1 1
165412 30 142 52 0100 5 188754 8 MAESTRO FRENTE A GRUPO 1 CALLE ... 2 1 2 1 1 2 2 2 1 2
165471 30 61 83 0219 2 190209 1 NaN 1 CARRETERA ... 2 2 1 2 1 2 2 2 1 2
165487 30 48 24 0217 6 189052 1 NaN 2 CARRETERA ... 2 2 1 2 1 2 2 2 1 2
165494 30 91 161 0171 11 189352 8 DIRECTOR COMISIONADO 1 CALLE ... 1 1 2 1 1 3 3 3 1 1
165643 30 144 1 0213 25 188439 1 NaN 1 CALLE ... 1 1 1 1 1 3 2 2 1 1
165661 31 59 1 0450 6 190771 1 NaN 1 CALLE ... 2 2 1 2 2 3 1 1 1 2
165712 30 89 19 0012 5 188464 1 NaN 1 GUILLERMO PRIETO ... 2 2 2 2 2 3 2 2 1 2
165716 30 89 52 0012 7 188468 1 NaN 1 GUILLERMO PRIETO ... 2 2 2 2 2 3 2 2 1 2
165785 30 144 37 0035 12 188448 1 NaN 1 CALLE ... 2 1 1 1 1 3 2 2 1 2
165844 31 52 2 0110 4 190927 2 NaN 2 CALLE ... 2 2 1 2 2 2 1 1 2 2
165853 30 142 29 0168 12 188725 1 NaN 2 CALLE ... 1 1 1 2 1 3 1 1 2 2
165980 30 210 30 0047 8 189638 8 DOCENTE 1 CALLE ... 9 9 9 9 9 3 2 2 1 2
165999 30 142 7 0100 7 188739 8 DIRECTORA ENCARGADA CON GRUPO 1 CALLE ... 2 2 1 1 1 2 2 2 1 1
166006 30 142 29 0168 12 188746 8 DIRECTOR CON GRUPO 1 CALLE ... 2 1 2 1 1 2 1 2 1 2
166031 30 61 17 0223 1 190173 1 NaN 1 CARRETERA ... 2 2 1 2 2 2 1 1 1 1
166032 30 61 17 0223 6 190174 8 DOCENTE 1 AVENIDA ... 2 2 2 1 1 3 2 2 2 2
166045 31 52 3 0106 14 190864 2 NaN 1 CALLE ... 1 1 1 1 1 2 2 1 2 2
166051 30 204 72 0105 800 189939 1 NaN 2 AVENIDA ... 2 1 1 1 1 3 2 2 2 1
166125 30 91 61 0063 3 189323 1 NaN 1 CALLE ... 1 1 1 1 1 3 2 2 2 2
166127 30 91 61 0063 2 189325 1 NaN 1 CALLE ... 2 2 2 2 1 3 2 3 2 3

3452 rows × 159 columns


In [13]:
#df2.ix[df2.P13A<1, 'P13A'] = 4
df2.ix[df2.P13A>4, 'P13A'] = 4
df2['P13A'].replace({1: 1.5, 2: 1, 3: 1, 4: 0},inplace=True)
#df2[df2['P13A']<1]['P13A']


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)

In [63]:
#df2.ix[df2.P14<1, 'P14'] = 3
df2.ix[df2.P14>3, 'P14'] = 3
df2['P14'].replace({1: 3, 2: 2, 3: 0},inplace=True)
#df2[df2['P14']<1]['P14']


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)

In [69]:
col='P15'
val = 4
df2.ix[df2.P15>val, col] = val
df2[col].replace({1: 3, 2: 2, 3: 2, 4: 0},inplace=True)
#print(max(df2[col]))
#print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)

In [71]:
col='P16'
val = 3
df2.ix[df2.P16>val, col] = val
df2[col].replace({1: 3, 2: 2, 3: 0},inplace=True)
#print(max(df2[col]))
#print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)

In [21]:
col='P17A'
val = 5
df2.ix[df2.P17A>val, col] = 4
df2[col].replace({1: 3, 2: 2, 3: 2, 4: 0, 5:1},inplace=True)
print(max(df2[col]))
print(min(df2[col]))


3.0
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)

In [22]:
col='P18A'
val = 5
df2.ix[df2.P18A>val, col] = val
df2[col].replace({1: 3, 2: 2, 3: 2, 4: 1, 5:0},inplace=True)
print(max(df2[col]))
print(min(df2[col]))


3.0
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)

In [23]:
col='P19'
val = 2
df2.ix[df2.P19>val, col] = val
df2[col].replace({1: 1, 2: 0},inplace=True)
print(max(df2[col]))
print(min(df2[col]))


1.0
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)

In [86]:
col='P20'
val = 2
df2.ix[df2.P20>val, col] = val
df2[col].replace({1: 3, 2: 0},inplace=True)
print(max(df2[col]))
print(min(df2[col]))
df2[col].unique()


3.0
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
Out[86]:
array([  0.,   3.,  nan])

In [25]:
col='P21'
val = 2
df2.ix[df2.P21>val, col] = val
df2[col].replace({1: 3, 2: 0},inplace=True)
print(max(df2[col]))
print(min(df2[col]))


3.0
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)

In [26]:
col='P22'
val = 2
df2.ix[df2.P22>val, col] = val
df2[col].replace({1: 3, 2: 0},inplace=True)
print(max(df2[col]))
print(min(df2[col]))


3.0
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)

In [81]:
col='P23'
val = 2
df2.ix[df2.P23>val, col] = val
df2[col].replace({1: 5.5, 2: 0},inplace=True)
print(max(df2[col]))
print(min(df2[col]))


5.5
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)

In [83]:
col='P24'
val = 2
df2.ix[df2.P24>val, col] = val
df2[col].replace({1: 5.5, 2: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


0
5.5
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [84]:
col='P25'
val = 2
df2.ix[df2.P25>val, col] = val
df2[col].replace({0: 0, 1: 0.5, 2: 1},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


0
1.0
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [85]:
col='P26'
val = 1
df2.ix[df2.P26>val, col] = val
#df2[col].replace({0: 0, 1: 1},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


0
1.0
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [86]:
col='P27'
val = 1
df2.ix[df2.P27>val, col] = val
#df2[col].replace({0: 0, 1: 1},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


0
1.0
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [87]:
col='P28'
val = 2
df2.ix[df2.P28>val, col] = val
df2[col].replace({0: 0.3, 1: 0, 2:0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


0
0.3
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [88]:
col='P29'
val = 2
df2.ix[df2.P29>val, col] = val
df2[col].replace({0: 0.3, 1: 0, 2:0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


0
0.3
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [89]:
col='P30'
val = 2
df2.ix[df2.P30>val, col] = val
df2[col].replace({0: 0.3, 1: 0, 2:0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


0
0.3
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [90]:
col='P31'
val = 2
df2.ix[df2.P31>val, col] = val
df2[col].replace({0: 0.3, 1: 0, 2:0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


0
0.3
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [91]:
col='P32'
val = 2
df2.ix[df2.P32>val, col] = val
df2[col].replace({0: 0.3, 1: 0, 2:0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


0
0.3
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [93]:
col='P33'
val = 2
df2.ix[df2.P33>val, col] = val
df2[col].replace({0: 0.5, 1: 0, 2:0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


0
0.5
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [94]:
col='P34'
val = 1
df2.ix[df2.P34>val, col] = val
#df2[col].replace({0: 0.3, 1: 0, 2:0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


0
1.0
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [95]:
col='P35'
val = 2
df2.ix[df2.P35>val, col] = val
df2[col].replace({0: 1.25, 1: 1, 2:0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


0
1.25
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [97]:
col='P36'
val = 1
df2.ix[df2.P36>val, col] = val
#df2[col].replace({0: 1.25, 1: 1, 2:0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


0
1.0
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [98]:
col='P37'
val = 2
df2.ix[df2.P37>val, col] = val
df2[col].replace({0: 1.25, 1: 1, 2:0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


0
1.25
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [99]:
col='P38'
val = 1
df2.ix[df2.P38>val, col] = val
#df2[col].replace({0: 1.25, 1: 1, 2:0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


0
1.0
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [100]:
col='P39'
val = 2
df2.ix[df2.P39>val, col] = val
df2[col].replace({0: 1.25, 1: 1, 2:0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


0
1.25
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [101]:
col='P40'
val = 1
df2.ix[df2.P40>val, col] = val
#df2[col].replace({0: 1.25, 1: 1, 2:0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


0
1.0
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [122]:
col='P41'
val = 2
df2.ix[df2.P41.isnull(), col] = 0
df2.ix[df2.P41>val, col] = val
df2[col].replace({0: 1.25, 1: 1, 2:0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
1.25
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [137]:
col='P42'
val = 3
df2.ix[df2.P42.isnull(), col] = 0
df2.ix[~(df2.P42>=val), col] = 0
df2.ix[df2.P42>=val, col] = 0.9

#df2[col].replace({0: 1.25, 1: 1, 2:0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)
0
0.9
0.0

In [138]:
col='P44'
val = 1
df2.ix[df2.P44.isnull(), col] = 0
df2.ix[df2.P44>val, col] = val
df2[col].replace({0: 0, 1: 0.8},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
0.8
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [139]:
col='P46'
val = 1
df2.ix[df2.P46.isnull(), col] = 0
df2.ix[df2.P46>val, col] = val
df2[col].replace({0: 0, 1: 0.8},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
0.8
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [140]:
col='P47'
val = 1
df2.ix[df2.P47.isnull(), col] = 0
df2.ix[df2.P47>val, col] = val
df2[col].replace({0: 0, 1: 0.8},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
0.8
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [141]:
col='P48'
val = 1
df2.ix[df2.P48.isnull(), col] = 0
df2.ix[df2.P48>val, col] = val
df2[col].replace({0: 0, 1: 0.8},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
0.8
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [142]:
col='P49'
val = 1
df2.ix[df2.P49.isnull(), col] = 0
df2.ix[df2.P49>val, col] = val
df2[col].replace({0: 0, 1: 0.8},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
0.8
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [143]:
col='P52'
val = 1
df2.ix[df2.P52.isnull(), col] = 0
df2.ix[df2.P52>val, col] = val
df2[col].replace({0: 2, 1: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
2.0
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [144]:
col='P62'
val = 1
df2.ix[df2.P62.isnull(), col] = 0
df2.ix[df2.P62>val, col] = val
df2[col].replace({0: 2, 1: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
2.0
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [145]:
col='P72'
val = 1
df2.ix[df2.P72.isnull(), col] = 0
df2.ix[df2.P72>val, col] = val
df2[col].replace({0: 2, 1: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
2.0
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [146]:
col='P82'
val = 1
df2.ix[df2.P82.isnull(), col] = 0
df2.ix[df2.P82>val, col] = val
df2[col].replace({0: 2, 1: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
2.0
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [147]:
col='P92'
val = 1
df2.ix[df2.P92.isnull(), col] = 0
df2.ix[df2.P92>val, col] = val
df2[col].replace({0: 2, 1: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
2.0
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [148]:
col='P102'
val = 2
df2.ix[df2.P102.isnull(), col] = 0
df2.ix[df2.P102>val, col] = val
df2[col].replace({1: .25, 2: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
0.25
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [150]:
col='P112'
val = 2
df2.ix[df2.P112.isnull(), col] = 0
df2.ix[df2.P112>val, col] = val
df2[col].replace({1: .25, 2: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
0.25
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [151]:
col='P113'
val = 2
df2.ix[df2.P113.isnull(), col] = 0
df2.ix[df2.P113>val, col] = val
df2[col].replace({1: .25, 2: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
0.25
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [152]:
col='P117'
val = 2
df2.ix[df2.P117.isnull(), col] = 0
df2.ix[df2.P117>val, col] = val
df2[col].replace({1: .25, 2: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
0.25
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [153]:
col='P122'
val = 2
df2.ix[df2.P122.isnull(), col] = 0
df2.ix[df2.P122>val, col] = val
df2[col].replace({1: .25, 2: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
0.25
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [154]:
col='P123'
val = 2
df2.ix[df2.P123.isnull(), col] = 0
df2.ix[df2.P123>val, col] = val
df2[col].replace({1: .25, 2: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
0.25
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [155]:
col='P125'
val = 2
df2.ix[df2.P125.isnull(), col] = 0
df2.ix[df2.P125>val, col] = val
df2[col].replace({1: .25, 2: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
0.25
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [156]:
col='P126'
val = 1
df2.ix[df2.P126.isnull(), col] = 0
df2.ix[df2.P126>val, col] = val
df2[col].replace({0: 0, 1: 2},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
2.0
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [158]:
col='P133'
val = 2
df2.ix[df2.P133.isnull(), col] = 0
df2.ix[df2.P133>val, col] = val
df2[col].replace({1: 1.2, 2: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
1.2
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [159]:
col='P134'
val = 2
df2.ix[df2.P134.isnull(), col] = 0
df2.ix[df2.P134>val, col] = val
df2[col].replace({1: 1.2, 2: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
1.2
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [160]:
col='P135'
val = 2
df2.ix[df2.P135.isnull(), col] = 0
df2.ix[df2.P135>val, col] = val
df2[col].replace({1: 1.2, 2: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
1.2
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [161]:
col='P136'
val = 2
df2.ix[df2.P136.isnull(), col] = 0
df2.ix[df2.P136>val, col] = val
df2[col].replace({1: 1.2, 2: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
1.2
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [162]:
col='P137'
val = 2
df2.ix[df2.P137.isnull(), col] = 0
df2.ix[df2.P137>val, col] = val
df2[col].replace({1: 1.2, 2: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
1.2
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [163]:
col='P138'
val = 2
df2.ix[df2.P138.isnull(), col] = 0
df2.ix[df2.P138>val, col] = val
df2[col].replace({1: 1.2, 2: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
1.2
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [164]:
col='P139'
val = 2
df2.ix[df2.P139.isnull(), col] = 0
df2.ix[df2.P139>val, col] = val
df2[col].replace({1: 1.2, 2: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
1.2
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [165]:
col='P140'
val = 2
df2.ix[df2.P140.isnull(), col] = 0
df2.ix[df2.P140>val, col] = val
df2[col].replace({1: 1.2, 2: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
1.2
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [167]:
col='P141'
val = 2
df2.ix[df2.P141.isnull(), col] = 0
df2.ix[df2.P141>val, col] = val
df2[col].replace({1: 0.4, 2: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
0.4
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [168]:
col='P142'
val = 2
df2.ix[df2.P142.isnull(), col] = 0
df2.ix[df2.P142>val, col] = val
df2[col].replace({1: 0.5, 2: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
0.5
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [169]:
col='P143'
val = 2
df2.ix[df2.P143.isnull(), col] = 0
df2.ix[df2.P143>val, col] = val
df2[col].replace({1: 0.5, 2: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
0.5
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [170]:
col='P144'
val = 2
df2.ix[df2.P144.isnull(), col] = 0
df2.ix[df2.P144>val, col] = val
df2[col].replace({1: 4, 2: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
4.0
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [171]:
col='P145'
val = 2
df2.ix[df2.P145.isnull(), col] = 0
df2.ix[df2.P145>val, col] = val
df2[col].replace({1: 4, 2: 0},inplace=True)
print(len(df2[df[col]<0]))
print(max(df2[col]))
print(min(df2[col]))


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)
0
4.0
0.0
/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py:1942: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  "DataFrame index.", UserWarning)

In [72]:
df2.to_csv('infraestuctura.csv')


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-72-abb3866e94a5> in <module>()
----> 1 df2.to_csv('infraestuctura.csv')
      2 df3 = df2[df2['P3']<6]

NameError: name 'df2' is not defined

In [71]:
print("nan:\t",len(df3[df3['P12'].isnull()]))
print("0:\t",len(df3[df3['P12']==0]))
print("1:\t",len(df3[df3['P12']==1]))
print(">2:\t",len(df3[df3['P12']>2]))
print("total:\t", len(df3['P12']))


nan:	 217
0:	 0
1:	 110794
>2:	 11059
total:	 151096

In [65]:
len(df3[df3['P12'].isnull()])


Out[65]:
217

In [88]:
pd.Series(df3['P12'].values.ravel()).unique()


Out[88]:
array([  1.,   2.,   3.,  nan])

In [52]:
from numpy import nan

In [93]:
df3 = df[df['P3']<6]

In [86]:
len(df3['P12'])


Out[86]:
151096

In [87]:
df3.ix[df3.P12>3, 'P12'] = 3


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s

In [91]:
len(df3[df3['P12']==3])


Out[91]:
11059

In [105]:
print("nan:\t",len(df3[df3['P12'].isnull()]))
print("1:\t",len(df3[df3['P12']==1]))
print("2:\t",len(df3[df3['P12']==2]))
print("3:\t",len(df3[df3['P12']==3]))
print("total:\t", len(df3['P12']))


nan:	 217
1:	 110794
2:	 29026
3:	 0
total:	 151096

In [95]:
df3.ix[df3.P12<1, 'P12'] = 3
df3.ix[df3.P12>2, 'P12'] = 3


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py:420: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s

In [98]:
df3['P12'].replace({1: 1.5, 1: 1, 3: 0},inplace=True)


/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py:3005: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._update_inplace(new_data)

In [88]:
df2['P12']


Out[88]:
0         1.5
1         1.5
2         1.5
3         1.5
4         1.5
5         1.5
6         1.5
7         1.5
8         1.0
9         1.5
10        1.5
11        1.5
12        1.5
13        1.5
14        1.5
15        1.0
16        1.5
17        1.5
18        1.5
19        1.5
20        1.5
21        1.5
22        1.5
23        1.5
24        1.5
25        1.5
26        1.5
27        1.5
28        1.5
29        1.5
         ... 
166106    1.5
166107    1.5
166108    1.5
166109    1.5
166110    1.0
166111    1.5
166112    1.5
166113    1.5
166114    1.5
166115    1.5
166116    1.5
166118    1.0
166119    1.5
166120    1.5
166121    1.5
166122    1.5
166123    1.0
166124    1.0
166125    1.0
166126    1.0
166127    1.0
166128    1.5
166129    1.5
166130    1.5
166132    1.5
166133    1.0
166134    1.0
166135    1.5
166136    1.0
166137    1.5
Name: P12, dtype: float64

In [103]:
len(df3[df3['P12']==0])


Out[103]:
11059

In [113]:
len(df[df['P12'].isnull()])


Out[113]:
14227

In [114]:
infr = pd.read_csv("infraestructura.csv")

In [115]:
print("nan:\t",len(infr[infr['P12'].isnull()]))
print("0:\t",len(infr[infr['P12']==0]))
print("1:\t",len(infr[infr['P12']==1]))
print("2:\t",len(infr[infr['P12']==2]))
print("total:\t", len(infr['P12']))


nan:	 217
0:	 11799
1:	 110188
2:	 28892
total:	 151096

In [90]:
print("nan:\t",len(df3[df3['P12'].isnull()]))
print("1:\t",len(df3[df3['P12']==1]))
print("2:\t",len(df3[df3['P12']==2]))
print("3:\t",len(df3[df3['P12']==3]))
print("total:\t", len(df3['P12']))


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-90-ab0f887322d9> in <module>()
----> 1 print("nan:\t",len(df3[df3['P12'].isnull()]))
      2 print("1:\t",len(df3[df3['P12']==1]))
      3 print("2:\t",len(df3[df3['P12']==2]))
      4 print("3:\t",len(df3[df3['P12']==3]))
      5 print("total:\t", len(df3['P12']))

NameError: name 'df3' is not defined

In [136]:
dif = infr['P12']==df3['P12']

In [129]:
dif.value()


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-129-8451647704cf> in <module>()
----> 1 dif.value()

/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/generic.py in __getattr__(self, name)
   2244                 return self[name]
   2245             raise AttributeError("'%s' object has no attribute '%s'" %
-> 2246                                  (type(self).__name__, name))
   2247 
   2248     def __setattr__(self, name, value):

AttributeError: 'Series' object has no attribute 'value'

In [143]:
lst=[]
s=0
for e in dif:
    s+=1
    if e==False:
        lst.append(s)

In [127]:
secciones = [['P3'], ['P11', 'P12', 'P13A', 'P14', 'P15', 'P16'], ['P17A', 'P18A', 'P19', 'P20', 'P21', 'P22'], ['P23', 'P24'], ['P25', 'P26', 'P27', 'P28', 'P29', 'P30', 'P31', 'P32', 'P33', 'P34', 'P35', 'P36', 'P37', 'P38', 'P39', 'P40', 'P41'], ['P42', 'P44', 'P46', 'P47', 'P48', 'P49', 'P52', 'P62', 'P72', 'P82', 'P92', 'P102', 'P103', 'P112', 'P113', 'P117', 'P122', 'P123', 'P125'], ['P126'], ['P133', 'P134', 'P135', 'P136', 'P137', 'P138', 'P139', 'P140', 'P141', 'P142', 'P143'], ['P144', 'P145']]
max_cal = [11, 13, 13, 11, 14, 17, 2, 11, 8]

In [75]:
#print(secciones[2][0],":\t",df4[secciones[2][0]].max())
#print(secciones[2][1],":\t",df4[secciones[2][1]].max())
#print(secciones[2][2],":\t",df4[secciones[2][2]].max())
#print(secciones[2][3],":\t",df4[secciones[2][3]].max())
df4[secciones[2]].sum(axis=1)


Out[75]:
13.0

In [76]:
infr = pd.read_csv("infraestructura.csv")

In [99]:
infr.ix[:,'P12'] = df2.ix[:,'P12']
infr.ix[:,'P20'] = df2.ix[:,'P20']

In [137]:
infr.to_csv('infraestuctura.csv')

In [98]:
infr['P12'].unique()


Out[98]:
array([ 1.5,  1. ,  0. ,  nan])

In [116]:
infr.ix[(infr['P20']==3) & (infr['P22']==3),'P20']=0

In [118]:
sec_lst


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-118-1426f0bbe641> in <module>()
----> 1 sec_lst

NameError: name 'sec_lst' is not defined

In [149]:
for j in range(9):
    tmp=infr[secciones[j]].sum(axis=1).max()
    print("Sección:", j+1,"\t",tmp, "<=", max_cal[j], "\t\t",  tmp<=max_cal[j])


Sección: 1 	 5 <= 11 		 True
Sección: 2 	 13.0 <= 13 		 True
Sección: 3 	 13.0 <= 13 		 True
Sección: 4 	 11.0 <= 11 		 True
Sección: 5 	 14.0 <= 14 		 True
Sección: 6 	 10.0 <= 17 		 True
Sección: 7 	 2.0 <= 2 		 True
Sección: 8 	 11.0 <= 11 		 True
Sección: 9 	 8.0 <= 8 		 True

In [150]:
infr[secciones]


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-150-0955b9af8e23> in <module>()
----> 1 infr[secciones]

/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py in __getitem__(self, key)
   1906         if isinstance(key, (Series, np.ndarray, Index, list)):
   1907             # either boolean or fancy integer index
-> 1908             return self._getitem_array(key)
   1909         elif isinstance(key, DataFrame):
   1910             return self._getitem_frame(key)

/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/frame.py in _getitem_array(self, key)
   1950             return self.take(indexer, axis=0, convert=False)
   1951         else:
-> 1952             indexer = self.ix._convert_to_indexer(key, axis=1)
   1953             return self.take(indexer, axis=1, convert=True)
   1954 

/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py in _convert_to_indexer(self, obj, axis, is_setter)
   1109                     # unique index
   1110                     if labels.is_unique:
-> 1111                         indexer = check = labels.get_indexer(objarr)
   1112 
   1113                     # non-unique (dups)

/Users/luis/anaconda/lib/python3.4/site-packages/pandas/core/index.py in get_indexer(self, target, method, limit, tolerance)
   1838                                  'backfill or nearest reindexing')
   1839 
-> 1840             indexer = self._engine.get_indexer(target._values)
   1841 
   1842         return com._ensure_platform_int(indexer)

pandas/index.pyx in pandas.index.IndexEngine.get_indexer (pandas/index.c:5840)()

pandas/hashtable.pyx in pandas.hashtable.PyObjectHashTable.lookup (pandas/hashtable.c:13174)()

TypeError: unhashable type: 'list'

In [ ]: