<jupyter_start><jupyter_text>Resumen de los datos<jupyter_code>import pandas as pd
import os
mainpath = "/Volumes/2ND_HDD/UDEMY/Curso Completo de Machine Learning/python-ml-course/datasets/"
localpath = "titanic/titanic3.csv"
fullpath = os.path.join(mainpath, localpath)
data = pd.read_csv(fullpath)
data.head(10)
#leer las dimensiones del dataset
data.shape

#obtener los nombres de las columnas
data.columns.values<jupyter_output><empty_output><jupyter_text>Resumen estadístico de los datos<jupyter_code>data.describe()
data.dtypes<jupyter_output><empty_output><jupyter_text>Missing Values<jupyter_code># devuelve los valores true or false en un array
#pd.isnull(data["body"]).values
# que todos los valores esten en una sola fila
#pd.isnull(data["body"]).values.ravel()
# suma los valores, siendo true = 1 y false = 0
pd.isnull(data["body"]).values.ravel().sum()<jupyter_output><empty_output><jupyter_text>Borrado de Valores que faltan<jupyter_code>data2 = data
data2 = data.dropna(axis=0, how="all")
data2.head(10)
data2["age"] = data2["age"].fillna(data["age"].mean())
data2["body"] = data2["body"].fillna(0)
data2["boat"] = data2["boat"].fillna(0)
data2["home.dest"] = data2["home.dest"].fillna("Unknown")
data2["cabin"] = data2["cabin"].fillna("Unknown")
data2["fare"] = data2["fare"].fillna(data["fare"].mean())
data2["embarked"] = data2["embarked"].fillna("Unknown")
data2<jupyter_output><empty_output><jupyter_text>Variables Dummy<jupyter_code>data["sex"].head(10)
#se generan variables donde si aparece male aparece un 1 en male y 0 en female y si 
#es female aparece 0 en male y 1 en female
dummy_sex = pd.get_dummies(data["sex"], prefix = "sex")
dummy_sex.head()
column_name = data.columns.values.tolist()
column_name
#creamos funcion donde elimine la columna sex y cree variables dummies
def createDummies(df, column):
    dummies = pd.get_dummies(df[column], prefix = column)
    df = df.drop(column, axis = 1)
    df = pd.concat([df, dummies], axis = 1)
    return df
data3 = createDummies(data2, "sex")
data3<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14841849148418493, 'fraction_numerical': 0.019464720194647202, 'mean_word_length': 6.847328244274809, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '530750', 'license': 'MIT', 'n_tokens_mistral': 786, 'n_tokens_neox': 772, 'n_words': 166, 'path': 'my notebooks/T1 - 2 - Data Cleaning - Analysis preliminar .ipynb', 'repo_name': 'diazidx/python-ml-course', 'size': '2055'}