Skip to content
Snippets Groups Projects
Commit 1c08b33b authored by Etienne Kornobis's avatar Etienne Kornobis
Browse files

update seaborn part

parent 210e8a02
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id:instrumental-personal tags: %% Cell type:markdown id:instrumental-personal tags:
# <center>**TP**</center> # <center>**TP**</center>
<div style="text-align:center"> <div style="text-align:center">
<img src="images/seaborn.png" width="600px"> <img src="images/seaborn.png" width="600px">
<div> <div>
Bertrand Néron, François Laurent, Etienne Kornobis Bertrand Néron, François Laurent, Etienne Kornobis
<br /> <br />
<a src=" https://research.pasteur.fr/en/team/bioinformatics-and-biostatistics-hub/">Bioinformatics and Biostatistiqucs HUB</a> <a src=" https://research.pasteur.fr/en/team/bioinformatics-and-biostatistics-hub/">Bioinformatics and Biostatistiqucs HUB</a>
<br /> <br />
© Institut Pasteur, 2021 © Institut Pasteur, 2021
</div> </div>
</div> </div>
%% Cell type:markdown id:compliant-basis tags: %% Cell type:markdown id:compliant-basis tags:
Practice your graphing skills using data from milieu intérieur in `data/mi.csv`: Practice your graphing skills using data from milieu intérieur in `data/mi.csv`:
%% Cell type:code id:minor-doctrine tags: %% Cell type:code id:minor-doctrine tags:
``` python ``` python
import pandas as pd import pandas as pd
import seaborn as sns import seaborn as sns
``` ```
%% Cell type:code id:skilled-daniel tags: %% Cell type:code id:skilled-daniel tags:
``` python ``` python
mi_df = pd.read_csv("data/mi.csv") mi_df = pd.read_csv("data/mi.csv")
``` ```
%% Cell type:code id:brutal-manufacturer tags: %% Cell type:code id:brutal-manufacturer tags:
``` python ``` python
mi_df.head() mi_df.head()
``` ```
%% Output %% Output
Unnamed: 0 Age OwnsHouse PhysicalActivity Sex LivesWithPartner \ Unnamed: 0 Age OwnsHouse PhysicalActivity Sex LivesWithPartner \
0 1 22.33 Yes 3.0 Female No 0 1 22.33 Yes 3.0 Female No
1 2 28.83 Yes 0.0 Female Yes 1 2 28.83 Yes 0.0 Female Yes
2 3 23.67 Yes 0.0 Female Yes 2 3 23.67 Yes 0.0 Female Yes
3 4 21.17 No 0.5 Female No 3 4 21.17 No 0.5 Female No
4 5 26.17 Yes 1.5 Female No 4 5 26.17 Yes 1.5 Female No
LivesWithKids BornInCity Inbreeding BMI ... VaccineWhoopingCough \ LivesWithKids BornInCity Inbreeding BMI ... VaccineWhoopingCough \
0 No Yes 94.9627 20.13 ... Yes 0 No Yes 94.9627 20.13 ... Yes
1 No Yes 79.1024 21.33 ... Yes 1 No Yes 79.1024 21.33 ... Yes
2 No Yes 117.2540 22.18 ... No 2 No Yes 117.2540 22.18 ... No
3 No No 94.1796 18.68 ... No 3 No No 94.1796 18.68 ... No
4 No Yes 105.1250 29.01 ... Yes 4 No Yes 105.1250 29.01 ... Yes
VaccineYellowFever VaccineHepB VaccineFlu SUBJID DepressionScore \ VaccineYellowFever VaccineHepB VaccineFlu SUBJID DepressionScore \
0 No Yes No 2 0.0 0 No Yes No 2 0.0
1 No Yes No 3 0.0 1 No Yes No 3 0.0
2 No Yes No 4 0.0 2 No Yes No 4 0.0
3 No Yes No 5 1.0 3 No Yes No 5 1.0
4 No Yes No 8 0.0 4 No Yes No 8 0.0
HeartRate Temperature HourOfSampling DayOfSampling HeartRate Temperature HourOfSampling DayOfSampling
0 66 36.8 8.883 40 0 66 36.8 8.883 40
1 66 37.4 9.350 40 1 66 37.4 9.350 40
2 62 36.9 8.667 40 2 62 36.9 8.667 40
3 64 36.0 9.883 40 3 64 36.0 9.883 40
4 67 36.7 8.550 81 4 67 36.7 8.550 81
[5 rows x 44 columns] [5 rows x 44 columns]
%% Cell type:markdown id:departmental-exhibition tags: %% Cell type:markdown id:departmental-exhibition tags:
- Do a boxplot showing the differences in temperature between females and males: - Do a boxplot showing the differences in temperature between females and males:
%% Cell type:code id:saved-identity tags: %% Cell type:code id:saved-identity tags:
``` python ``` python
sns.boxplot(data=mi_df, x="Sex", y="Temperature") sns.boxplot(data=mi_df, x="Sex", y="Temperature")
``` ```
%% Output %% Output
<AxesSubplot:xlabel='Sex', ylabel='Temperature'> <AxesSubplot:xlabel='Sex', ylabel='Temperature'>
%% Cell type:markdown id:portuguese-worse tags: %% Cell type:markdown id:portuguese-worse tags:
- Using an histogram, display the distribution of age in the dataset - Using an histogram and continuous probability density curve, display the distribution of age in the dataset
%% Cell type:code id:continuous-indian tags: %% Cell type:code id:continuous-indian tags:
``` python ``` python
sns.histplot(data=mi_df, x="Age") sns.histplot(data=mi_df, x="Age")
``` ```
%% Output %% Output
<AxesSubplot:xlabel='Age', ylabel='Count'> <AxesSubplot:xlabel='Age', ylabel='Count'>
%% Cell type:code id:understanding-vegetarian tags: %% Cell type:code id:understanding-vegetarian tags:
``` python ``` python
sns.histplot(data=mi_df, x="Age", kde=True) sns.histplot(data=mi_df, x="Age", kde=True)
``` ```
%% Output %% Output
<AxesSubplot:xlabel='Age', ylabel='Count'> <AxesSubplot:xlabel='Age', ylabel='Count'>
%% Cell type:markdown id:prepared-stephen tags: %% Cell type:markdown id:prepared-stephen tags:
- Use a barplot to show the count of vaccinated for yellow fever (see the documentation for a countplot) - Use a barplot to show the count of vaccinated for yellow fever (see the documentation for a countplot)
%% Cell type:code id:worldwide-communication tags: %% Cell type:code id:worldwide-communication tags:
``` python ``` python
sns.countplot(data=mi_df, x="VaccineYellowFever") sns.countplot(data=mi_df, x="VaccineYellowFever")
``` ```
%% Output %% Output
<AxesSubplot:xlabel='VaccineYellowFever', ylabel='count'> <AxesSubplot:xlabel='VaccineYellowFever', ylabel='count'>
%% Cell type:markdown id:immediate-method tags: %% Cell type:markdown id:immediate-method tags:
- Plot the distribution of age for the people vaccinated for the flu - Plot the distribution of age for the people vaccinated for the flu
%% Cell type:code id:academic-measure tags: %% Cell type:code id:academic-measure tags:
``` python ``` python
sns.histplot(data=mi_df.query("VaccineFlu == 'Yes'"), x="Age", kde=True) sns.histplot(data=mi_df.query("VaccineFlu == 'Yes'"), x="Age", kde=True)
``` ```
%% Output %% Output
<AxesSubplot:xlabel='Age', ylabel='Count'> <AxesSubplot:xlabel='Age', ylabel='Count'>
%% Cell type:markdown id:temporal-synthesis tags: %% Cell type:markdown id:temporal-synthesis tags:
- Feel free to explore more of [seaborn](https://seaborn.pydata.org/examples/index.html) ! - Feel free to explore more of [seaborn](https://seaborn.pydata.org/examples/index.html) !
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment