Tabla de Contenidos

5. Pandas: Apendices

Tratamiento de datos inválidos

df.capacidad.isna()

[False, True,  False, True,  False, False, False, False, False, False, 
 False, False, False, False, False, False, False, False, False, False, 
 False, False, False, False, False, False, False, False, False, False]

df.capacidad.notna()

[True, False, True, False, True, True, True, True, True, True, 
 True, True,  True, True,  True, True, True, True, True, True, 
 True, True,  True, True,  True, True, True, True, True, True]

new_df=df[df.capacidad.notna()]

df[(df.tipo.notna()) & (df.capacidad.notna()) & (df.precio.notna())]

df.fillna(df.mean(),inplace=True)
new_df=df.fillna(df.mean())

df['tipo']=df.tipo.fillna("Desconocido")

df['precio']=df.precio.fillna(df.precio.mean())

pandas_profiling

Genera un HTML con información del DataFrame

from pandas_profiling import ProfileReport
reporte = ProfileReport(df, title = "Mi reporte")
reporte.to_file("reporte.html")

Se puede ver el resultado en pandas_profiling.html

Mas información: