<jupyter_start><jupyter_text>Datos del Titanic<jupyter_code>import seaborn as sns
titanic = sns.load_dataset("titanic")
titanic.head()
titanic.shape
import numpy as np
import pandas as pd
titanic['survived'] = pd.Categorical(titanic['survived'])
titanic['pclass'] = pd.Categorical(titanic['pclass'])
titanic['sex'] = pd.Categorical(titanic['sex'])
titanic['deck'] = pd.Categorical(titanic['deck'])<jupyter_output><empty_output><jupyter_text>Tablas de frecuencias de una variable<jupyter_code>tab = pd.crosstab(index = titanic['survived'],
                 columns = 'pasajeros')
tab
type(tab)
pd.crosstab(index = titanic['pclass'],
           columns = "pasajeros")
pd.crosstab(index = titanic['sex'], 
           columns = "pasajeros")
tab_c = pd.crosstab(index = titanic['deck'],
           columns = "count")
tab_c
tab_c.sum()
tab_c.shape
tab_c.iloc[1:5]
tab_c/tab_c.sum()<jupyter_output><empty_output><jupyter_text>Tablas de contingencia de dos variable<jupyter_code>survived_sex = pd.crosstab(index = titanic['survived'],
                          columns = titanic['sex'])
survived_sex.index = ["died", "survived"]
survived_sex
survived_class = pd.crosstab(index = titanic['survived'], 
                            columns = titanic['pclass'],
                            margins = True)

survived_class.index = ["murio", "sobrevivio", "total_clase"]
survived_class.columns = ["primera", "segunda", "tercera", "total_superv"]
survived_class<jupyter_output><empty_output><jupyter_text>Frecuencias relativas globales<jupyter_code>survived_class/survived_class.loc["total_clase", "total_superv"]<jupyter_output><empty_output><jupyter_text>Frecuencias relativas marginales<jupyter_code>survived_class/survived_class.loc["total_clase"]
survived_class.div(survived_class.loc["total_clase"], axis = 1)
survived_class.T/survived_class["total_superv"]
survived_class.div(survived_class["total_superv"], axis = 0)<jupyter_output><empty_output><jupyter_text>Tablas multi dimensionales<jupyter_code>surv_sex_class = pd.crosstab(index = titanic["survived"],
                            columns = [titanic["sex"], titanic["pclass"]],
                            margins = True)
surv_sex_class
surv_sex_class["female"]
surv_sex_class["female"][1]
surv_sex_class/surv_sex_class.loc["All"]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1386481802426343, 'fraction_numerical': 0.002166377816291161, 'mean_word_length': 5.326027397260274, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '210527', 'license': 'MIT', 'n_tokens_mistral': 887, 'n_tokens_neox': 866, 'n_words': 110, 'path': 'scripts/tema6/05-titanic.ipynb', 'repo_name': 'Adipiz/EstadisticaDescriptiva', 'size': '2308'}