From 5c75142c76a2e6c2d68f00679277d0b97188b81b Mon Sep 17 00:00:00 2001
From: 906a4f494f4ba26c398ed74cb4de7b36
<906a4f494f4ba26c398ed74cb4de7b36@app-learninglab.inria.fr>
Date: Wed, 11 Nov 2020 14:44:39 +0000
Subject: [PATCH] no commit message
---
module2/exo1/cars.csv | 51 +++
..._notebooks_notebook_Jupyter_Python_R.ipynb | 389 ++++++++++++++++++
module2/exo1/toy_notebook_en.ipynb | 25 --
module2/exo1/toy_notebook_fr.ipynb | 22 +-
4 files changed, 449 insertions(+), 38 deletions(-)
create mode 100644 module2/exo1/cars.csv
create mode 100644 module2/exo1/documents_notebooks_notebook_Jupyter_Python_R.ipynb
delete mode 100644 module2/exo1/toy_notebook_en.ipynb
diff --git a/module2/exo1/cars.csv b/module2/exo1/cars.csv
new file mode 100644
index 0000000..34b3d46
--- /dev/null
+++ b/module2/exo1/cars.csv
@@ -0,0 +1,51 @@
+"","speed","dist"
+"1",4,2
+"2",4,10
+"3",7,4
+"4",7,22
+"5",8,16
+"6",9,10
+"7",10,18
+"8",10,26
+"9",10,34
+"10",11,17
+"11",11,28
+"12",12,14
+"13",12,20
+"14",12,24
+"15",12,28
+"16",13,26
+"17",13,34
+"18",13,34
+"19",13,46
+"20",14,26
+"21",14,36
+"22",14,60
+"23",14,80
+"24",15,20
+"25",15,26
+"26",15,54
+"27",16,32
+"28",16,40
+"29",17,32
+"30",17,40
+"31",17,50
+"32",18,42
+"33",18,56
+"34",18,76
+"35",18,84
+"36",19,36
+"37",19,46
+"38",19,68
+"39",20,32
+"40",20,48
+"41",20,52
+"42",20,56
+"43",20,64
+"44",22,66
+"45",23,54
+"46",24,70
+"47",24,92
+"48",24,93
+"49",24,120
+"50",25,85
diff --git a/module2/exo1/documents_notebooks_notebook_Jupyter_Python_R.ipynb b/module2/exo1/documents_notebooks_notebook_Jupyter_Python_R.ipynb
new file mode 100644
index 0000000..59e591c
--- /dev/null
+++ b/module2/exo1/documents_notebooks_notebook_Jupyter_Python_R.ipynb
@@ -0,0 +1,389 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Notebook Python R\n",
+ "\n",
+ "## Import des données dans Python"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " Unnamed: 0 | \n",
+ " speed | \n",
+ " dist | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 0 | \n",
+ " 1 | \n",
+ " 4 | \n",
+ " 2 | \n",
+ "
\n",
+ " \n",
+ " 1 | \n",
+ " 2 | \n",
+ " 4 | \n",
+ " 10 | \n",
+ "
\n",
+ " \n",
+ " 2 | \n",
+ " 3 | \n",
+ " 7 | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 3 | \n",
+ " 4 | \n",
+ " 7 | \n",
+ " 22 | \n",
+ "
\n",
+ " \n",
+ " 4 | \n",
+ " 5 | \n",
+ " 8 | \n",
+ " 16 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " Unnamed: 0 speed dist\n",
+ "0 1 4 2\n",
+ "1 2 4 10\n",
+ "2 3 7 4\n",
+ "3 4 7 22\n",
+ "4 5 8 16"
+ ]
+ },
+ "execution_count": 3,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "import pandas as pd\n",
+ "# data_url = \"https://forge.scilab.org/index.php/p/rdataset/source/file/master/csv/datasets/cars.csv\"\n",
+ "data_url = \"cars.csv\"\n",
+ "df_python = pd.read_csv(data_url)\n",
+ "df_python.head()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Supression de la première colonne"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " speed | \n",
+ " dist | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 0 | \n",
+ " 4 | \n",
+ " 2 | \n",
+ "
\n",
+ " \n",
+ " 1 | \n",
+ " 4 | \n",
+ " 10 | \n",
+ "
\n",
+ " \n",
+ " 2 | \n",
+ " 7 | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 3 | \n",
+ " 7 | \n",
+ " 22 | \n",
+ "
\n",
+ " \n",
+ " 4 | \n",
+ " 8 | \n",
+ " 16 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " speed dist\n",
+ "0 4 2\n",
+ "1 4 10\n",
+ "2 7 4\n",
+ "3 7 22\n",
+ "4 8 16"
+ ]
+ },
+ "execution_count": 4,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "df_python.drop(df_python.columns[[0]], axis=1, inplace=True)\n",
+ "df_python.head()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Summary avec Python"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " speed | \n",
+ " dist | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " count | \n",
+ " 50.000000 | \n",
+ " 50.000000 | \n",
+ "
\n",
+ " \n",
+ " mean | \n",
+ " 15.400000 | \n",
+ " 42.980000 | \n",
+ "
\n",
+ " \n",
+ " std | \n",
+ " 5.287644 | \n",
+ " 25.769377 | \n",
+ "
\n",
+ " \n",
+ " min | \n",
+ " 4.000000 | \n",
+ " 2.000000 | \n",
+ "
\n",
+ " \n",
+ " 25% | \n",
+ " 12.000000 | \n",
+ " 26.000000 | \n",
+ "
\n",
+ " \n",
+ " 50% | \n",
+ " 15.000000 | \n",
+ " 36.000000 | \n",
+ "
\n",
+ " \n",
+ " 75% | \n",
+ " 19.000000 | \n",
+ " 56.000000 | \n",
+ "
\n",
+ " \n",
+ " max | \n",
+ " 25.000000 | \n",
+ " 120.000000 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " speed dist\n",
+ "count 50.000000 50.000000\n",
+ "mean 15.400000 42.980000\n",
+ "std 5.287644 25.769377\n",
+ "min 4.000000 2.000000\n",
+ "25% 12.000000 26.000000\n",
+ "50% 15.000000 36.000000\n",
+ "75% 19.000000 56.000000\n",
+ "max 25.000000 120.000000"
+ ]
+ },
+ "execution_count": 5,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "df_python.describe()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Summary avec R"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from rpy2.robjects import pandas2ri\n",
+ "pandas2ri.activate()\n",
+ "from rpy2.robjects.packages import importr"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "scrolled": true
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ " speed dist \n",
+ " Min. : 4.0 Min. : 2.00 \n",
+ " 1st Qu.:12.0 1st Qu.: 26.00 \n",
+ " Median :15.0 Median : 36.00 \n",
+ " Mean :15.4 Mean : 42.98 \n",
+ " 3rd Qu.:19.0 3rd Qu.: 56.00 \n",
+ " Max. :25.0 Max. :120.00 \n",
+ "\n"
+ ]
+ }
+ ],
+ "source": [
+ "base = importr('base')\n",
+ "print(base.summary(df_python))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {},
+ "outputs": [
+ {
+ "ename": "RRuntimeError",
+ "evalue": "Error in loadNamespace(name) : there is no package called ‘prettyR’\n",
+ "output_type": "error",
+ "traceback": [
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
+ "\u001b[0;31mRRuntimeError\u001b[0m Traceback (most recent call last)",
+ "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mprettyR\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mimportr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'prettyR'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mprettyR\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdescribe\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdf_python\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+ "\u001b[0;32m/opt/conda/lib/python3.6/site-packages/rpy2/robjects/packages.py\u001b[0m in \u001b[0;36mimportr\u001b[0;34m(name, lib_loc, robject_translations, signature_translation, suppress_messages, on_conflict, symbol_r2python, symbol_check_after, data)\u001b[0m\n\u001b[1;32m 451\u001b[0m if _package_has_namespace(rname, \n\u001b[1;32m 452\u001b[0m _system_file(package = rname)):\n\u001b[0;32m--> 453\u001b[0;31m \u001b[0menv\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_get_namespace\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mrname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 454\u001b[0m \u001b[0mversion\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_get_namespace_version\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mrname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 455\u001b[0m \u001b[0mexported_names\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mset\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0m_get_namespace_exports\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mrname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+ "\u001b[0;31mRRuntimeError\u001b[0m: Error in loadNamespace(name) : there is no package called ‘prettyR’\n"
+ ]
+ }
+ ],
+ "source": [
+ "prettyR = importr('prettyR')\n",
+ "print(prettyR.describe(df_python))"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Liens utiles\n",
+ "\n",
+ "- http://rpy.sourceforge.net/rpy2/doc-2.4/html/introduction.html\n",
+ "- https://rpy2.readthedocs.io/en/version_2.8.x/"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.6.4"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/module2/exo1/toy_notebook_en.ipynb b/module2/exo1/toy_notebook_en.ipynb
deleted file mode 100644
index 0bbbe37..0000000
--- a/module2/exo1/toy_notebook_en.ipynb
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "cells": [],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.6.3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
-}
-
diff --git a/module2/exo1/toy_notebook_fr.ipynb b/module2/exo1/toy_notebook_fr.ipynb
index f34037b..960879b 100644
--- a/module2/exo1/toy_notebook_fr.ipynb
+++ b/module2/exo1/toy_notebook_fr.ipynb
@@ -96,21 +96,17 @@
],
"metadata": {
"kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
+ "display_name": "R",
+ "language": "R",
+ "name": "ir"
},
"language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.6.4"
+ "codemirror_mode": "r",
+ "file_extension": ".r",
+ "mimetype": "text/x-r-source",
+ "name": "R",
+ "pygments_lexer": "r",
+ "version": "3.4.1"
}
},
"nbformat": 4,
--
2.18.1