# Analyses sur le titanic :::info ## Histplot ![](https://hackmd.io/_uploads/rk4W-_wEh.png) ::: :::info ## boite à moustache ![](https://hackmd.io/_uploads/SJjU-uPN2.png) ::: :::info ## countplot ![](https://hackmd.io/_uploads/H1oLWuDV2.png) ::: :::info * Moyenne de tous les ages : 30 ans * Ecart type des ages : 14 ans * Médiane des ages : 28 ans * Personne la plus agée à bord du titanic : 80 ans * Personne la moin agée à bord du titanic : moins d'un an #### Quartiles : 1. 20.5 ans 2. 28 ans 3. 38 ans ::: ```python import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt sns.set_style('whitegrid') titanic = sns.load_dataset('titanic') sns.load_dataset('titanic') titanic = pd.read_csv('./train.csv') titanic.head() # Boite à moustache sns.boxplot(x='Pclass',y='Age',data=titanic) plt.show() # count plot sns.countplot(x='Sex',data=titanic) plt.show() # Graphique sns.histplot(titanic["Fare"],kde=False) plt.show() age = titanic["Age"] age = age[np.logical_not(np.isnan(age))] # Moyenne age moyenne = sum(age) / len(age) print("Moyenne des ages : " + str(round(moyenne))) # Ecart type print("ecart type des ages : " + str(round(np.std(age)))) # Médiane print("Médiane des ages : " + str(np.percentile(age, 50))) # Maximum print("Age maximum : " + str(np.max(age))) # Minimum print("Age minimum : " + str(np.min(age))) # Quartiles : print("Premier quartile : " + str(np.percentile(age, 25))) print("Deuxième quartile : " + str(np.percentile(age, 50))) print("Troisième quartile : " + str(np.percentile(age, 75))) ```