import numpy as np
ma_liste = [1,20,13,40,25]
# Afficher la liste
ma_liste
# ou print(ma_liste)
[1, 20, 13, 40, 25]
# creer un vecteur numpy a partir d'une liste
mon_vecteur = np.array(ma_liste)
mon_vecteur
array([ 1, 20, 13, 40, 25])
# Acceder au deuxieme element
mon_vecteur[1]
20
mon_vecteur[-4]
20
# accerder au dernier element
mon_vecteur[4]
25
mon_vecteur[-1]
25
# accerder au 2eme 3eme et 4eme element
# mon_vecteur[1:4]
# ou
mon_vecteur[-4:-1]
array([20, 13, 40])
mon_vecteur[1:4]
array([20, 13, 40])
# Les matrice
ma_liste2 = [1,-20,3,4,50]
ma_liste2
[1, -20, 3, 4, 50]
ma_matrice = [ma_liste,ma_liste2]
ma_matrice
[[1, 20, 13, 40, 25], [1, -20, 3, 4, 50]]
ma_matrice_np = np.array(ma_matrice)
ma_matrice_np
array([[ 1, 20, 13, 40, 25],
[ 1, -20, 3, 4, 50]])
# premiere ligne
ma_matrice_np[0]
array([ 1, 20, 13, 40, 25])
# 3eme element de la premiere ligne
ma_matrice_np[0][2]
13
ma_matrice_np[-1][-2]
4
ma_matrice_np[-1][3]
4
# premiere etape: il faut importer la librairie pandas
import pandas as pd
# charger la base de données
df =pd.read_csv("DBM1.csv",sep=';')
df.head() # affiche les 05 premières lignes
| T | P | S | F | C | |
|---|---|---|---|---|---|
| 0 | 180 | 70 | h | 2 | brun |
| 1 | 177 | 57 | h | 3 | brun |
| 2 | 180 | 60 | h | 1 | bleu |
| 3 | 180 | 66 | h | 0 | brun |
| 4 | 183 | 62 | h | 6 | vert |
# afficher les 05 dernières lignes
df.tail()
| T | P | S | F | C | |
|---|---|---|---|---|---|
| 40 | 158 | 62 | f | 0 | brun |
| 41 | 161 | 65 | f | 1 | brun |
| 42 | 160 | 61 | f | 1 | bleu |
| 43 | 162 | 58 | f | 2 | brun |
| 44 | 165 | 58 | f | 5 | brun |
# Afficher la dimmension
#df.shape
df.shape
(45, 5)
# afficher les colonnes
df.columns
Index(['T', 'P', 'S', 'F', 'C'], dtype='object')
# Afficher les types des colonnes
df.dtypes
T int64 P int64 S object F int64 C object dtype: object
# infos sur les donnees
df.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 45 entries, 0 to 44 Data columns (total 5 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 T 45 non-null int64 1 P 45 non-null int64 2 S 45 non-null object 3 F 45 non-null int64 4 C 45 non-null object dtypes: int64(3), object(2) memory usage: 1.9+ KB
# Description des données
df.describe()
| T | P | F | |
|---|---|---|---|
| count | 45.000000 | 45.000000 | 45.000000 |
| mean | 174.311111 | 65.088889 | 1.933333 |
| std | 8.836449 | 8.953979 | 1.601136 |
| min | 157.000000 | 47.000000 | 0.000000 |
| 25% | 167.000000 | 59.000000 | 1.000000 |
| 50% | 177.000000 | 65.000000 | 2.000000 |
| 75% | 181.000000 | 71.000000 | 3.000000 |
| max | 190.000000 | 98.000000 | 7.000000 |
df.describe(include ='all')
| T | P | S | F | C | |
|---|---|---|---|---|---|
| count | 45.000000 | 45.000000 | 45 | 45.000000 | 45 |
| unique | NaN | NaN | 2 | NaN | 5 |
| top | NaN | NaN | h | NaN | brun |
| freq | NaN | NaN | 30 | NaN | 23 |
| mean | 174.311111 | 65.088889 | NaN | 1.933333 | NaN |
| std | 8.836449 | 8.953979 | NaN | 1.601136 | NaN |
| min | 157.000000 | 47.000000 | NaN | 0.000000 | NaN |
| 25% | 167.000000 | 59.000000 | NaN | 1.000000 | NaN |
| 50% | 177.000000 | 65.000000 | NaN | 2.000000 | NaN |
| 75% | 181.000000 | 71.000000 | NaN | 3.000000 | NaN |
| max | 190.000000 | 98.000000 | NaN | 7.000000 | NaN |
df.describe(include ='object')
| S | C | |
|---|---|---|
| count | 45 | 45 |
| unique | 2 | 5 |
| top | h | brun |
| freq | 30 | 23 |
# afficher la colonne T
df['T'].head()
0 180 1 177 2 180 3 180 4 183 Name: T, dtype: int64
# afficher la colonne C
df['C'].head()
0 brun 1 brun 2 bleu 3 brun 4 vert Name: C, dtype: object
# afficher les colonnes P et S
df[['P','S']].head()
| P | S | |
|---|---|---|
| 0 | 70 | h |
| 1 | 57 | h |
| 2 | 60 | h |
| 3 | 66 | h |
| 4 | 62 | h |
# decrire la variable T
df['T'].describe()
count 45.000000 mean 174.311111 std 8.836449 min 157.000000 25% 167.000000 50% 177.000000 75% 181.000000 max 190.000000 Name: T, dtype: float64
# calculer explicitement des parametres statistique
# df['T'].mean()
# df['T'].std()
#df['T'].min()
#df['T'].max()
df['T'].median()
177.0
df['T'].mean()
174.3111111111111
df['T'].std()
8.836448850235499
df['T'].min()
157
df['T'].max()
190
# afficher la 1ere taille
df['T'][0]
180
# afficher la 10ieme taille
df['T'][9]
180
# afficher la 6ieme taille
df['T'][5]
184
# trier les valeurs
df['T'].sort_values().head()
31 157 40 158 42 160 41 161 43 162 Name: T, dtype: int64
## tri généralisé d'un data frame
# trier le data set par ordre croissant de T
df.sort_values(by ='T')
| T | P | S | F | C | |
|---|---|---|---|---|---|
| 31 | 157 | 47 | f | 1 | vert |
| 40 | 158 | 62 | f | 0 | brun |
| 42 | 160 | 61 | f | 1 | bleu |
| 41 | 161 | 65 | f | 1 | brun |
| 43 | 162 | 58 | f | 2 | brun |
| 34 | 163 | 65 | f | 1 | brun |
| 37 | 164 | 49 | f | 7 | vert |
| 44 | 165 | 58 | f | 5 | brun |
| 39 | 165 | 59 | f | 2 | bleu |
| 36 | 166 | 68 | f | 2 | bleu |
| 32 | 167 | 53 | f | 2 | vert |
| 35 | 167 | 60 | f | 2 | brun |
| 17 | 167 | 60 | h | 4 | bleu |
| 33 | 168 | 57 | f | 4 | bleu |
| 10 | 168 | 52 | h | 3 | brun |
| 30 | 168 | 52 | f | 0 | brun |
| 21 | 170 | 68 | h | 1 | gris |
| 22 | 170 | 59 | h | 3 | brun |
| 38 | 172 | 57 | f | 3 | brun |
| 20 | 173 | 75 | h | 1 | vert |
| 8 | 174 | 65 | h | 3 | noir |
| 27 | 176 | 65 | h | 1 | vert |
| 1 | 177 | 57 | h | 3 | brun |
| 28 | 178 | 72 | h | 1 | brun |
| 19 | 179 | 98 | h | 2 | brun |
| 24 | 179 | 73 | h | 3 | vert |
| 0 | 180 | 70 | h | 2 | brun |
| 14 | 180 | 65 | h | 4 | brun |
| 2 | 180 | 60 | h | 1 | bleu |
| 25 | 180 | 72 | h | 3 | bleu |
| 3 | 180 | 66 | h | 0 | brun |
| 9 | 180 | 72 | h | 2 | brun |
| 11 | 180 | 75 | h | 0 | bleu |
| 18 | 181 | 67 | h | 0 | brun |
| 13 | 181 | 68 | h | 0 | bleu |
| 4 | 183 | 62 | h | 6 | vert |
| 23 | 183 | 72 | h | 2 | bleu |
| 16 | 183 | 78 | h | 0 | bleu |
| 12 | 183 | 75 | h | 2 | brun |
| 7 | 184 | 72 | h | 2 | brun |
| 5 | 184 | 68 | h | 0 | brun |
| 6 | 185 | 65 | h | 1 | noir |
| 29 | 185 | 71 | h | 1 | bleu |
| 26 | 188 | 70 | h | 2 | brun |
| 15 | 190 | 66 | h | 1 | brun |
# trier le data set par ordre croissant de T puis de P
df.sort_values(by =['T','P'])
| T | P | S | F | C | |
|---|---|---|---|---|---|
| 31 | 157 | 47 | f | 1 | vert |
| 40 | 158 | 62 | f | 0 | brun |
| 42 | 160 | 61 | f | 1 | bleu |
| 41 | 161 | 65 | f | 1 | brun |
| 43 | 162 | 58 | f | 2 | brun |
| 34 | 163 | 65 | f | 1 | brun |
| 37 | 164 | 49 | f | 7 | vert |
| 44 | 165 | 58 | f | 5 | brun |
| 39 | 165 | 59 | f | 2 | bleu |
| 36 | 166 | 68 | f | 2 | bleu |
| 32 | 167 | 53 | f | 2 | vert |
| 17 | 167 | 60 | h | 4 | bleu |
| 35 | 167 | 60 | f | 2 | brun |
| 10 | 168 | 52 | h | 3 | brun |
| 30 | 168 | 52 | f | 0 | brun |
| 33 | 168 | 57 | f | 4 | bleu |
| 22 | 170 | 59 | h | 3 | brun |
| 21 | 170 | 68 | h | 1 | gris |
| 38 | 172 | 57 | f | 3 | brun |
| 20 | 173 | 75 | h | 1 | vert |
| 8 | 174 | 65 | h | 3 | noir |
| 27 | 176 | 65 | h | 1 | vert |
| 1 | 177 | 57 | h | 3 | brun |
| 28 | 178 | 72 | h | 1 | brun |
| 24 | 179 | 73 | h | 3 | vert |
| 19 | 179 | 98 | h | 2 | brun |
| 2 | 180 | 60 | h | 1 | bleu |
| 14 | 180 | 65 | h | 4 | brun |
| 3 | 180 | 66 | h | 0 | brun |
| 0 | 180 | 70 | h | 2 | brun |
| 9 | 180 | 72 | h | 2 | brun |
| 25 | 180 | 72 | h | 3 | bleu |
| 11 | 180 | 75 | h | 0 | bleu |
| 18 | 181 | 67 | h | 0 | brun |
| 13 | 181 | 68 | h | 0 | bleu |
| 4 | 183 | 62 | h | 6 | vert |
| 23 | 183 | 72 | h | 2 | bleu |
| 12 | 183 | 75 | h | 2 | brun |
| 16 | 183 | 78 | h | 0 | bleu |
| 5 | 184 | 68 | h | 0 | brun |
| 7 | 184 | 72 | h | 2 | brun |
| 6 | 185 | 65 | h | 1 | noir |
| 29 | 185 | 71 | h | 1 | bleu |
| 26 | 188 | 70 | h | 2 | brun |
| 15 | 190 | 66 | h | 1 | brun |
## Acces indicé au données d'un dataFrame avec loc et iloc
# acces a la cellule d'indice (0,0)
df.iloc[0,0]
180
# acces a la cellule d'indice (42,2)
df.iloc[42,2]
'f'
# cinq premieres lignes
df.iloc[0:5,:]
| T | P | S | F | C | |
|---|---|---|---|---|---|
| 0 | 180 | 70 | h | 2 | brun |
| 1 | 177 | 57 | h | 3 | brun |
| 2 | 180 | 60 | h | 1 | bleu |
| 3 | 180 | 66 | h | 0 | brun |
| 4 | 183 | 62 | h | 6 | vert |
# deux premieres colonnes
df.iloc[:,0:2]
| T | P | |
|---|---|---|
| 0 | 180 | 70 |
| 1 | 177 | 57 |
| 2 | 180 | 60 |
| 3 | 180 | 66 |
| 4 | 183 | 62 |
| 5 | 184 | 68 |
| 6 | 185 | 65 |
| 7 | 184 | 72 |
| 8 | 174 | 65 |
| 9 | 180 | 72 |
| 10 | 168 | 52 |
| 11 | 180 | 75 |
| 12 | 183 | 75 |
| 13 | 181 | 68 |
| 14 | 180 | 65 |
| 15 | 190 | 66 |
| 16 | 183 | 78 |
| 17 | 167 | 60 |
| 18 | 181 | 67 |
| 19 | 179 | 98 |
| 20 | 173 | 75 |
| 21 | 170 | 68 |
| 22 | 170 | 59 |
| 23 | 183 | 72 |
| 24 | 179 | 73 |
| 25 | 180 | 72 |
| 26 | 188 | 70 |
| 27 | 176 | 65 |
| 28 | 178 | 72 |
| 29 | 185 | 71 |
| 30 | 168 | 52 |
| 31 | 157 | 47 |
| 32 | 167 | 53 |
| 33 | 168 | 57 |
| 34 | 163 | 65 |
| 35 | 167 | 60 |
| 36 | 166 | 68 |
| 37 | 164 | 49 |
| 38 | 172 | 57 |
| 39 | 165 | 59 |
| 40 | 158 | 62 |
| 41 | 161 | 65 |
| 42 | 160 | 61 |
| 43 | 162 | 58 |
| 44 | 165 | 58 |
### les requetes
# Lister les hommes
df.loc[df['S']=="h",:]
| T | P | S | F | C | |
|---|---|---|---|---|---|
| 0 | 180 | 70 | h | 2 | brun |
| 1 | 177 | 57 | h | 3 | brun |
| 2 | 180 | 60 | h | 1 | bleu |
| 3 | 180 | 66 | h | 0 | brun |
| 4 | 183 | 62 | h | 6 | vert |
| 5 | 184 | 68 | h | 0 | brun |
| 6 | 185 | 65 | h | 1 | noir |
| 7 | 184 | 72 | h | 2 | brun |
| 8 | 174 | 65 | h | 3 | noir |
| 9 | 180 | 72 | h | 2 | brun |
| 10 | 168 | 52 | h | 3 | brun |
| 11 | 180 | 75 | h | 0 | bleu |
| 12 | 183 | 75 | h | 2 | brun |
| 13 | 181 | 68 | h | 0 | bleu |
| 14 | 180 | 65 | h | 4 | brun |
| 15 | 190 | 66 | h | 1 | brun |
| 16 | 183 | 78 | h | 0 | bleu |
| 17 | 167 | 60 | h | 4 | bleu |
| 18 | 181 | 67 | h | 0 | brun |
| 19 | 179 | 98 | h | 2 | brun |
| 20 | 173 | 75 | h | 1 | vert |
| 21 | 170 | 68 | h | 1 | gris |
| 22 | 170 | 59 | h | 3 | brun |
| 23 | 183 | 72 | h | 2 | bleu |
| 24 | 179 | 73 | h | 3 | vert |
| 25 | 180 | 72 | h | 3 | bleu |
| 26 | 188 | 70 | h | 2 | brun |
| 27 | 176 | 65 | h | 1 | vert |
| 28 | 178 | 72 | h | 1 | brun |
| 29 | 185 | 71 | h | 1 | bleu |
# Lister les femmes
df.loc[df['S']=="f",:]
| T | P | S | F | C | |
|---|---|---|---|---|---|
| 30 | 168 | 52 | f | 0 | brun |
| 31 | 157 | 47 | f | 1 | vert |
| 32 | 167 | 53 | f | 2 | vert |
| 33 | 168 | 57 | f | 4 | bleu |
| 34 | 163 | 65 | f | 1 | brun |
| 35 | 167 | 60 | f | 2 | brun |
| 36 | 166 | 68 | f | 2 | bleu |
| 37 | 164 | 49 | f | 7 | vert |
| 38 | 172 | 57 | f | 3 | brun |
| 39 | 165 | 59 | f | 2 | bleu |
| 40 | 158 | 62 | f | 0 | brun |
| 41 | 161 | 65 | f | 1 | brun |
| 42 | 160 | 61 | f | 1 | bleu |
| 43 | 162 | 58 | f | 2 | brun |
| 44 | 165 | 58 | f | 5 | brun |
# les hommes ayant des yeux bleu ou noir
df2= df.loc[df['S']=="h",:]
df2.loc[df2['C'].isin(['bleu']),:]
| T | P | S | F | C | |
|---|---|---|---|---|---|
| 2 | 180 | 60 | h | 1 | bleu |
| 11 | 180 | 75 | h | 0 | bleu |
| 13 | 181 | 68 | h | 0 | bleu |
| 16 | 183 | 78 | h | 0 | bleu |
| 17 | 167 | 60 | h | 4 | bleu |
| 23 | 183 | 72 | h | 2 | bleu |
| 25 | 180 | 72 | h | 3 | bleu |
| 29 | 185 | 71 | h | 1 | bleu |
# les hommes ayant des yeux bleu ou noir
df2= df.loc[df['S']=="h",:]
df2.loc[df2['C'].isin(['bleu','noir']),:]
| T | P | S | F | C | |
|---|---|---|---|---|---|
| 2 | 180 | 60 | h | 1 | bleu |
| 6 | 185 | 65 | h | 1 | noir |
| 8 | 174 | 65 | h | 3 | noir |
| 11 | 180 | 75 | h | 0 | bleu |
| 13 | 181 | 68 | h | 0 | bleu |
| 16 | 183 | 78 | h | 0 | bleu |
| 17 | 167 | 60 | h | 4 | bleu |
| 23 | 183 | 72 | h | 2 | bleu |
| 25 | 180 | 72 | h | 3 | bleu |
| 29 | 185 | 71 | h | 1 | bleu |
# utilisation des operateurs logiques
# ET = &
# OU = |
# Negation - tilde
# les hommes ayant des yeux bleu
df.loc[(df['S']=="h") & (df['C']=="bleu"),:]
| T | P | S | F | C | |
|---|---|---|---|---|---|
| 2 | 180 | 60 | h | 1 | bleu |
| 11 | 180 | 75 | h | 0 | bleu |
| 13 | 181 | 68 | h | 0 | bleu |
| 16 | 183 | 78 | h | 0 | bleu |
| 17 | 167 | 60 | h | 4 | bleu |
| 23 | 183 | 72 | h | 2 | bleu |
| 25 | 180 | 72 | h | 3 | bleu |
| 29 | 185 | 71 | h | 1 | bleu |
# les femmes ayant des yeux bleu ou noir
df.loc[((df['S']=="f") & (df['C']=="bleu"))| ((df['S']=="f") & (df['C']=="noir")),:]
| T | P | S | F | C | |
|---|---|---|---|---|---|
| 33 | 168 | 57 | f | 4 | bleu |
| 36 | 166 | 68 | f | 2 | bleu |
| 39 | 165 | 59 | f | 2 | bleu |
| 42 | 160 | 61 | f | 1 | bleu |
# #liste des personnes de moins de 75 kilos, de sexe masculin, présentant ayant des yeux noir
df.loc[(df['P'] < 75) & (df['S'] == "h") & (df['C'] == "noir"),:]
| T | P | S | F | C | |
|---|---|---|---|---|---|
| 6 | 185 | 65 | h | 1 | noir |
| 8 | 174 | 65 | h | 3 | noir |
# meme question mais afficher poids, sexe et couleur des yeux
colonnes = ['P','S','C']
df.loc[(df['P'] < 75) & (df['S'] == "h") & (df['C'] == "noir"),colonnes]
| P | S | C | |
|---|---|---|---|
| 6 | 65 | h | noir |
| 8 | 65 | h | noir |
### Croisement des variable
#fréquences selon sexe et couleur des yeux- cela ressemnble à table() de R
#voir : http://pandas.pydata.org/pandas-docs/stable/generated/pandas.crosstab.ht ml
pd.crosstab(df['S'],df['C'])
| C | bleu | brun | gris | noir | vert |
|---|---|---|---|---|---|
| S | |||||
| f | 4 | 8 | 0 | 0 | 3 |
| h | 8 | 15 | 1 | 2 | 4 |
# meme question en affichant le poutrcentage
pd.crosstab(df['S'],df['C'], normalize='index')
| C | bleu | brun | gris | noir | vert |
|---|---|---|---|---|---|
| S | |||||
| f | 0.266667 | 0.533333 | 0.000000 | 0.000000 | 0.200000 |
| h | 0.266667 | 0.500000 | 0.033333 | 0.066667 | 0.133333 |
import matplotlib.pyplot as plt
# Generer 10 nombre compris en 0et 2
x=np.linspace(0,2,10)
x
array([0. , 0.22222222, 0.44444444, 0.66666667, 0.88888889,
1.11111111, 1.33333333, 1.55555556, 1.77777778, 2. ])
y =x**2
y
array([0. , 0.04938272, 0.19753086, 0.44444444, 0.79012346,
1.2345679 , 1.77777778, 2.41975309, 3.16049383, 4. ])
plt.plot(x,y)
plt.show()
# Ajouter des parametres
plt.plot(x,y,c='yellow',lw=10,ls='--')
plt.show()
# Modifier la taille du graphique
plt.figure(figsize=(6,6))
plt.plot(x,y,c='black',lw=5,ls='--')
plt.show()
# Plusieurs figures sur un même graphique
z=x**3
plt.plot(x,y)
plt.plot(x,z)
plt.show()
# Ajouter l'etiquettes des axes , un titre et une legende
plt.plot(x,y,label='quadratique')
plt.plot(x,x**3,label='cubique')
plt.title('Figure 5')
plt.xlabel('Axe x')
plt.ylabel('Axe y')
plt.legend()
plt.show()
# Plusieurs graphiques avec subplot
plt.subplot(2,1,1)
plt.plot(x,y,label='quadratique', c='red')
plt.title('Figure 5')
plt.xlabel('Axe x')
plt.ylabel('Axe y')
plt.legend()
plt.subplot(2,1,2)
plt.plot(x,x**3,label='Cubique',c='blue')
plt.xlabel('Axe x')
plt.ylabel('Axe y')
plt.legend()
plt.show()
# Plusieurs graphiques avec subplot
plt.subplot(1,2,1)
plt.plot(x,y,label='quadratique', c='red')
plt.title('Figure 5')
plt.xlabel('Axe x')
plt.ylabel('Axe y')
plt.legend()
plt.subplot(1,2,2)
plt.plot(x,x**3,label='Cubique',c='blue')
plt.xlabel('Axe x')
plt.ylabel('Axe y')
plt.legend()
plt.show()
# Diagramme en batonnet
z = [0,1,2,3,4,5,6,7 ]
t = [8,12,12,7,3,1,1,1]
plt.bar(z,t, width = 0.04, color = 'blue')
plt.title('Diagrammes en baton')
plt.xlabel('Nombre de frere(s)')
plt.ylabel('Effectif')
plt.show()
# Boxplot
box_plot_data=df['F']
plt.boxplot(box_plot_data,labels=['Nombre de frere(s)'])
plt.title('Boxplot')
plt.show()
# Boxplot
box_plot_data=df['F']
plt.boxplot(box_plot_data,patch_artist=True,labels=['Nombre de frere(s)'])
plt.title('Boxplot')
plt.show()
# Histogrammes
y = df['T']
plt.hist(y,5, histtype='bar',align='mid', color='c', label='Taille',edgecolor='black')
plt.title('Histogramme')
plt.legend()
plt.show()
y = df['T']
plt.hist(y,5,align='mid', color='c', label='Taille',edgecolor='black', orientation = 'horizontal')
plt.legend()
plt.ylabel('Taiile')
plt.xlabel('Frequences')
plt.title('Histogramme')
plt.show()
### Barplot simple
haut = [12,23,1,2,7]
bars = ('bleu', 'brun', 'gris', 'noir', 'vert')
# Creer les barres
plt.bar(bars, haut)
# ajouter des nons a l'axe des abcisses
plt.xticks(bars)
# afficher le graphe
plt.show()
# Pie / camembert
# pie plot simple
plt.figure(figsize = (8, 8)) # agrandir l'affichage
x = [12,23,1,2,7]
plt.pie(x, labels = ['bleu', 'brun', 'gris', 'noir', 'vert'])
plt.legend()
plt.show()
# le scarter plot (nuage de points)
x = df['T']
y = df['P']
plt.scatter(x, y)
plt.xlabel('Taille')
plt.ylabel('Poids')
plt.title('Nuage de point')
plt.show()
value1 = df[df.S=='h']['T']
value2=df[df.S=='f']['T']
box_plot_data=[value1,value2]
plt.boxplot(box_plot_data, labels=['Homme','Femme'])
plt.title('Boxplot')
plt.show()
## histogrammes supperposés des taiiles par sexe
value1 = df[df.S=='h']['T']
value2=df[df.S=='f']['T']
plt.hist([value1, value2], bins = 5, color = ['yellow', 'green'],
edgecolor = 'red', hatch = '/', label = ['Homme', '.Femmes'],
histtype = 'barstacked')
plt.ylabel('valeurs')
plt.xlabel('nombres')
plt.title('2 series superposees')
plt.legend()
plt.show()
value1 = df[df.S=='h']['T']
value2=df[df.S=='f']['T']
box_plot_data=[value1,value2]
plt.boxplot(box_plot_data, labels=['Homme','Femme'])
plt.title('Boxplot')
plt.show()
### Barplot double
data = [[5., 25., 50., 20.],[4., 23., 51., 17.]]
X = np.arange(4)
plt.bar(X + 0.00, data[0], color = 'b', width = 0.25)
plt.bar(X + 0.25, data[1], color = 'g', width = 0.25)
plt.show()