2017-2018/3e/Gestion_donnees/Statistiques/Taille et poids des merous.ipynb

152 lines
2.7 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Création de données sur la taille des poissons"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import pandas as pd\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
"d = np.random.normal(60, 15, 15)"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [],
"source": [
"d = d.astype(int)"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"w = [round(l/9+np.random.normal(),2) for l in d]"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"dt = {\"Taille\": d,\n",
" \"Poids\": w}"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [],
"source": [
"df = pd.DataFrame(dt)"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"9.11 & 81.0 \\\\\n",
"\\hline\n",
"9.66 & 78.0 \\\\\n",
"\\hline\n",
"9.55 & 80.0 \\\\\n",
"\\hline\n",
"7.87 & 79.0 \\\\\n",
"\\hline\n",
"8.24 & 64.0 \\\\\n",
"\\hline\n",
"5.46 & 50.0 \\\\\n",
"\\hline\n",
"5.89 & 56.0 \\\\\n",
"\\hline\n",
"7.9 & 78.0 \\\\\n",
"\\hline\n",
"6.98 & 75.0 \\\\\n",
"\\hline\n",
"5.37 & 49.0 \\\\\n",
"\\hline\n",
"6.03 & 53.0 \\\\\n",
"\\hline\n",
"7.29 & 63.0 \\\\\n",
"\\hline\n",
"3.98 & 38.0 \\\\\n",
"\\hline\n",
"6.08 & 40.0 \\\\\n",
"\\hline\n",
"7.02 & 69.0 \\\\\n",
"\\hline\n"
]
}
],
"source": [
"for d in df.values:\n",
" print(f\"{d[0]} & {d[1]} \\\\\\\\\")\n",
" print(\"\\\\hline\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"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
}