Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
scientific_python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hub-courses
scientific_python
Commits
1c08b33b
Commit
1c08b33b
authored
2 years ago
by
Etienne Kornobis
Browse files
Options
Downloads
Patches
Plain Diff
update seaborn part
parent
210e8a02
No related branches found
No related tags found
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
notebooks/seaborn_TP_solutions.ipynb
+6
-6
6 additions, 6 deletions
notebooks/seaborn_TP_solutions.ipynb
notebooks/seaborn_cours.ipynb
+871
-224
871 additions, 224 deletions
notebooks/seaborn_cours.ipynb
with
877 additions
and
230 deletions
notebooks/seaborn_TP_solutions.ipynb
+
6
−
6
View file @
1c08b33b
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
4
,
"execution_count":
1
,
"id": "minor-doctrine",
"id": "minor-doctrine",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
...
@@ -40,7 +40,7 @@
...
@@ -40,7 +40,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
9
,
"execution_count":
2
,
"id": "skilled-daniel",
"id": "skilled-daniel",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
...
@@ -311,7 +311,7 @@
...
@@ -311,7 +311,7 @@
"id": "portuguese-worse",
"id": "portuguese-worse",
"metadata": {},
"metadata": {},
"source": [
"source": [
"- 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"
]
]
},
},
{
{
...
@@ -473,9 +473,9 @@
...
@@ -473,9 +473,9 @@
],
],
"metadata": {
"metadata": {
"kernelspec": {
"kernelspec": {
"display_name": "Python
3 (ipykernel)
",
"display_name": "Python
[conda env:dev]
",
"language": "python",
"language": "python",
"name": "
python3
"
"name": "
conda-env-dev-py
"
},
},
"language_info": {
"language_info": {
"codemirror_mode": {
"codemirror_mode": {
...
@@ -487,7 +487,7 @@
...
@@ -487,7 +487,7 @@
"name": "python",
"name": "python",
"nbconvert_exporter": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"pygments_lexer": "ipython3",
"version": "3.
8.
10"
"version": "3.10
.4
"
}
}
},
},
"nbformat": 4,
"nbformat": 4,
...
...
%% 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.
Click to expand it.
notebooks/seaborn_cours.ipynb
+
871
−
224
View file @
1c08b33b
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment