# Analyses sur le titanic :::info ## Histplot  ::: :::info ## boite à moustache  ::: :::info ## countplot  ::: :::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))) ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up