Commit d3ce2c00 authored by Etienne Kornobis's avatar Etienne Kornobis
Browse files

add seaborn course

parent 075f6061
......@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "lesser-criticism",
"id": "horizontal-listening",
"metadata": {},
"source": [
"# <center>**Cours**</center>\n",
......@@ -21,7 +21,7 @@
},
{
"cell_type": "markdown",
"id": "attempted-certificate",
"id": "sophisticated-concept",
"metadata": {},
"source": [
"# Intro\n",
......@@ -51,7 +51,7 @@
},
{
"cell_type": "markdown",
"id": "angry-banking",
"id": "velvet-payroll",
"metadata": {},
"source": [
"# Installation\n",
......@@ -70,7 +70,7 @@
},
{
"cell_type": "markdown",
"id": "british-currency",
"id": "falling-radar",
"metadata": {},
"source": [
"# Import Convention"
......@@ -78,8 +78,8 @@
},
{
"cell_type": "code",
"execution_count": 2,
"id": "proud-coffee",
"execution_count": 171,
"id": "executed-tsunami",
"metadata": {},
"outputs": [],
"source": [
......@@ -89,7 +89,7 @@
},
{
"cell_type": "markdown",
"id": "english-subdivision",
"id": "foster-convert",
"metadata": {},
"source": [
"# Series\n",
......@@ -103,8 +103,8 @@
},
{
"cell_type": "code",
"execution_count": 68,
"id": "outer-brass",
"execution_count": 172,
"id": "musical-civilization",
"metadata": {},
"outputs": [
{
......@@ -113,7 +113,7 @@
"pandas.core.series.Series"
]
},
"execution_count": 68,
"execution_count": 172,
"metadata": {},
"output_type": "execute_result"
}
......@@ -125,8 +125,8 @@
},
{
"cell_type": "code",
"execution_count": 69,
"id": "executive-right",
"execution_count": 173,
"id": "superb-relaxation",
"metadata": {},
"outputs": [
{
......@@ -138,7 +138,7 @@
"dtype: int64"
]
},
"execution_count": 69,
"execution_count": 173,
"metadata": {},
"output_type": "execute_result"
}
......@@ -149,7 +149,7 @@
},
{
"cell_type": "markdown",
"id": "personal-cleaners",
"id": "coordinated-issue",
"metadata": {},
"source": [
"You can specify the labels of your Series by providing a list of labels as\n",
......@@ -158,8 +158,8 @@
},
{
"cell_type": "code",
"execution_count": 4,
"id": "spatial-disposal",
"execution_count": 174,
"id": "received-flash",
"metadata": {},
"outputs": [
{
......@@ -171,7 +171,7 @@
"dtype: int64"
]
},
"execution_count": 4,
"execution_count": 174,
"metadata": {},
"output_type": "execute_result"
}
......@@ -183,7 +183,7 @@
},
{
"cell_type": "markdown",
"id": "reduced-retention",
"id": "sorted-optimum",
"metadata": {},
"source": [
"And we can access these indices with the `index` property:"
......@@ -191,8 +191,8 @@
},
{
"cell_type": "code",
"execution_count": 109,
"id": "classical-sapphire",
"execution_count": 175,
"id": "immune-physiology",
"metadata": {},
"outputs": [
{
......@@ -201,7 +201,7 @@
"RangeIndex(start=0, stop=3, step=1)"
]
},
"execution_count": 109,
"execution_count": 175,
"metadata": {},
"output_type": "execute_result"
}
......@@ -212,8 +212,8 @@
},
{
"cell_type": "code",
"execution_count": 110,
"id": "known-absorption",
"execution_count": 176,
"id": "systematic-working",
"metadata": {},
"outputs": [
{
......@@ -222,7 +222,7 @@
"Index(['A', 'B', 'C'], dtype='object')"
]
},
"execution_count": 110,
"execution_count": 176,
"metadata": {},
"output_type": "execute_result"
}
......@@ -233,7 +233,7 @@
},
{
"cell_type": "markdown",
"id": "amateur-secret",
"id": "arctic-gibson",
"metadata": {},
"source": [
"## Indexing/Slicing\n",
......@@ -243,8 +243,8 @@
},
{
"cell_type": "code",
"execution_count": 86,
"id": "exact-accuracy",
"execution_count": 177,
"id": "alternate-banks",
"metadata": {},
"outputs": [
{
......@@ -253,7 +253,7 @@
"2"
]
},
"execution_count": 86,
"execution_count": 177,
"metadata": {},
"output_type": "execute_result"
}
......@@ -264,8 +264,8 @@
},
{
"cell_type": "code",
"execution_count": 81,
"id": "hairy-inspiration",
"execution_count": 178,
"id": "standing-train",
"metadata": {},
"outputs": [
{
......@@ -274,7 +274,7 @@
"2"
]
},
"execution_count": 81,
"execution_count": 178,
"metadata": {},
"output_type": "execute_result"
}
......@@ -285,8 +285,8 @@
},
{
"cell_type": "code",
"execution_count": 106,
"id": "social-extra",
"execution_count": 179,
"id": "severe-correlation",
"metadata": {},
"outputs": [
{
......@@ -297,7 +297,7 @@
"dtype: int64"
]
},
"execution_count": 106,
"execution_count": 179,
"metadata": {},
"output_type": "execute_result"
}
......@@ -308,8 +308,8 @@
},
{
"cell_type": "code",
"execution_count": 107,
"id": "diagnostic-flood",
"execution_count": 180,
"id": "raising-grenada",
"metadata": {},
"outputs": [
{
......@@ -321,7 +321,7 @@
"dtype: int64"
]
},
"execution_count": 107,
"execution_count": 180,
"metadata": {},
"output_type": "execute_result"
}
......@@ -332,7 +332,7 @@
},
{
"cell_type": "markdown",
"id": "mysterious-airline",
"id": "blocked-roommate",
"metadata": {},
"source": [
"Most commonly, You can use **labels** as well for subsetting, using the `loc` attribute:"
......@@ -340,8 +340,8 @@
},
{
"cell_type": "code",
"execution_count": 79,
"id": "private-profession",
"execution_count": 181,
"id": "accompanied-pantyhose",
"metadata": {},
"outputs": [
{
......@@ -350,7 +350,7 @@
"2"
]
},
"execution_count": 79,
"execution_count": 181,
"metadata": {},
"output_type": "execute_result"
}
......@@ -361,7 +361,7 @@
},
{
"cell_type": "markdown",
"id": "forbidden-conjunction",
"id": "durable-lesson",
"metadata": {},
"source": [
"**WARNING**: With `loc`, the value is interpreted as a label of the\n",
......@@ -372,8 +372,8 @@
},
{
"cell_type": "code",
"execution_count": 87,
"id": "hawaiian-fever",
"execution_count": 182,
"id": "comparative-guinea",
"metadata": {},
"outputs": [
{
......@@ -382,7 +382,7 @@
"1"
]
},
"execution_count": 87,
"execution_count": 182,
"metadata": {},
"output_type": "execute_result"
}
......@@ -393,7 +393,7 @@
},
{
"cell_type": "markdown",
"id": "prescribed-literature",
"id": "convenient-constitution",
"metadata": {},
"source": [
"Serie objects benefit from many attributes and methods (see [pandas documentation](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.html)), lot's of them being common with pandas DataFrames. We will see some of the one listed below in action in the DataFrame section of this course.\n",
......@@ -433,7 +433,7 @@
},
{
"cell_type": "markdown",
"id": "precious-green",
"id": "arabic-affairs",
"metadata": {},
"source": [
"## Operations on Series\n",
......@@ -445,8 +445,8 @@
},
{
"cell_type": "code",
"execution_count": 100,
"id": "optimum-drama",
"execution_count": 183,
"id": "million-richards",
"metadata": {},
"outputs": [
{
......@@ -458,7 +458,7 @@
"dtype: bool"
]
},
"execution_count": 100,
"execution_count": 183,
"metadata": {},
"output_type": "execute_result"
}
......@@ -469,7 +469,7 @@
},
{
"cell_type": "markdown",
"id": "twenty-planet",
"id": "unlike-monaco",
"metadata": {},
"source": [
"Since `loc` can take list or Series of booleans as input, we can then apply this Boolean Serie as a mask for our Serie:"
......@@ -477,8 +477,8 @@
},
{
"cell_type": "code",
"execution_count": 101,
"id": "universal-responsibility",
"execution_count": 184,
"id": "ordered-rendering",
"metadata": {},
"outputs": [
{
......@@ -489,7 +489,7 @@
"dtype: int64"
]
},
"execution_count": 101,
"execution_count": 184,
"metadata": {},
"output_type": "execute_result"
}
......@@ -500,7 +500,7 @@
},
{
"cell_type": "markdown",
"id": "pressed-clark",
"id": "major-intermediate",
"metadata": {},
"source": [
"## Operations between Series"
......@@ -508,7 +508,7 @@
},
{
"cell_type": "markdown",
"id": "thick-meter",
"id": "suitable-focus",
"metadata": {},
"source": [
"Operations (ie `+`, `-`, `*`, `/`) between Series will trigger an alignment of the values\n",
......@@ -517,8 +517,8 @@
},
{
"cell_type": "code",
"execution_count": 103,
"id": "departmental-creature",
"execution_count": 185,
"id": "least-cruise",
"metadata": {},
"outputs": [
{
......@@ -530,7 +530,7 @@
"dtype: int64"
]
},
"execution_count": 103,
"execution_count": 185,
"metadata": {},
"output_type": "execute_result"
}
......@@ -541,7 +541,7 @@
},
{
"cell_type": "markdown",
"id": "regulation-listening",
"id": "herbal-collaboration",
"metadata": {},
"source": [
"We can see here that the label are aligned prior operation"
......@@ -549,8 +549,8 @@
},
{
"cell_type": "code",
"execution_count": 108,
"id": "electric-cherry",
"execution_count": 186,
"id": "better-blame",
"metadata": {},
"outputs": [
{
......@@ -562,7 +562,7 @@
"dtype: int64"
]
},
"execution_count": 108,
"execution_count": 186,
"metadata": {},
"output_type": "execute_result"
}
......@@ -573,7 +573,7 @@
},
{
"cell_type": "markdown",
"id": "positive-batman",
"id": "loved-orleans",
"metadata": {},
"source": [
"# DataFrames\n",
......@@ -593,8 +593,8 @@
},
{
"cell_type": "code",
"execution_count": 122,
"id": "following-houston",
"execution_count": 187,
"id": "regulated-ready",
"metadata": {},
"outputs": [
{
......@@ -646,7 +646,7 @@
"b 4 5 6"
]
},
"execution_count": 122,
"execution_count": 187,
"metadata": {},
"output_type": "execute_result"
}
......@@ -661,8 +661,8 @@
},
{
"cell_type": "code",
"execution_count": 123,
"id": "personalized-kennedy",
"execution_count": 188,
"id": "stable-discharge",
"metadata": {},
"outputs": [
{
......@@ -671,7 +671,7 @@
"Index(['a', 'b'], dtype='object')"
]
},
"execution_count": 123,
"execution_count": 188,
"metadata": {},
"output_type": "execute_result"
}
......@@ -682,8 +682,8 @@
},
{
"cell_type": "code",
"execution_count": 124,
"id": "conceptual-boards",
"execution_count": 189,
"id": "configured-coral",
"metadata": {},
"outputs": [
{
......@@ -692,7 +692,7 @@
"Index(['A', 'B', 'C'], dtype='object')"
]
},
"execution_count": 124,
"execution_count": 189,
"metadata": {},
"output_type": "execute_result"
}
......@@ -703,7 +703,7 @@
},
{
"cell_type": "markdown",
"id": "agricultural-spotlight",
"id": "exclusive-brave",
"metadata": {},
"source": [
"### From a numpy ndarray"
......@@ -711,8 +711,8 @@
},
{
"cell_type": "code",
"execution_count": 9,
"id": "minor-korean",
"execution_count": 190,
"id": "facial-curve",
"metadata": {},
"outputs": [
{
......@@ -778,7 +778,7 @@
"3 9 10 11"
]
},
"execution_count": 9,
"execution_count": 190,
"metadata": {},
"output_type": "execute_result"
}
......@@ -790,16 +790,16 @@
},
{
"cell_type": "markdown",
"id": "still-commissioner",
"id": "committed-planning",
"metadata": {},
"source": [
"- From a dictionnary"
"### From a dictionnary"
]
},
{
"cell_type": "code",
"execution_count": 115,
"id": "intellectual-wilson",
"execution_count": 191,
"id": "suspected-nirvana",
"metadata": {},
"outputs": [
{
......@@ -854,7 +854,7 @@
"2 3 6"
]
},
"execution_count": 115,
"execution_count": 191,
"metadata": {},
"output_type": "execute_result"
}
......@@ -869,7 +869,7 @@
},
{
"cell_type": "markdown",
"id": "international-checkout",
"id": "vocational-peoples",
"metadata": {},
"source": [
"- From a file, many options are available, to name only a few:\n",
......@@ -882,8 +882,8 @@
},
{
"cell_type": "code",
"execution_count": 5,
"id": "bronze-prayer",
"execution_count": 192,
"id": "sonic-shock",
"metadata": {
"tags": []
},
......@@ -894,7 +894,7 @@
},
{
"cell_type": "markdown",
"id": "laden-composer",
"id": "about-cursor",
"metadata": {},
"source": [
"We want to open *data/bar_data.tsv* file but the 2 first lines are comments and the separator between fields is *tab*\n",
......@@ -904,8 +904,8 @@
},
{
"cell_type": "code",
"execution_count": 6,
"id": "grave-party",
"execution_count": 193,
"id": "bridal-development",
"metadata": {},
"outputs": [
{
......@@ -926,8 +926,8 @@
},
{
"cell_type": "code",
"execution_count": 10,
"id": "historical-ivory",
"execution_count": 194,
"id": "listed-framework",
"metadata": {},
"outputs": [
{
......@@ -1006,7 +1006,7 @@
"4 9.080359 5.629192 18.443504 4.268572"
]
},
"execution_count": 10,
"execution_count": 194,
"metadata": {},
"output_type": "execute_result"
}
......@@ -1018,7 +1018,7 @@
},
{
"cell_type": "markdown",
"id": "bacterial-irrigation",
"id": "explicit-monitoring",
"metadata": {},
"source": [
"If the data in the file are already indexed like in this one:"
......@@ -1026,8 +1026,8 @@
},
{
"cell_type": "code",
"execution_count": 11,
"id": "supported-health",
"execution_count": 195,
"id": "allied-artist",
"metadata": {},
"outputs": [
{
......@@ -1048,8 +1048,8 @@
},
{
"cell_type": "code",
"execution_count": 12,
"id": "discrete-anaheim",
"execution_count": 196,
"id": "limiting-tokyo",
"metadata": {},
"outputs": [
{
......@@ -1116,7 +1116,7 @@
"2 2 2.11 383.40 437.458982 15.040385"
]
},
"execution_count": 12,
"execution_count": 196,
"metadata": {},
"output_type": "execute_result"
}
......@@ -1128,17 +1128,17 @@
},
{
"cell_type": "markdown",
"id": "latest-public",
"id": "european-tunisia",
"metadata": {},
"source": [
"To avoiding to have an extra column, you can specify which columns to use as index.\n",
"To avoid to have an extra column, you can specify which columns to use as index.\n",
"This column **must** have distincts values."
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "casual-buying",
"execution_count": 197,
"id": "crucial-flight",
"metadata": {},
"outputs": [
{
......@@ -1217,7 +1217,7 @@