Add source example files

This commit is contained in:
2025-07-12 18:43:56 +02:00
parent 11d6846f49
commit d0bcfcf8f1
62 changed files with 40101 additions and 161 deletions

View File

@ -1,161 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "e1ab7cf7-6cf4-4ba6-b3a1-9c4d3d4aa8e9",
"metadata": {},
"source": [
"# Bienvenue dans Jupyter\n",
"\n",
"Cette cellule contient du texte en **Markdown**"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "e7b050ca-32bd-4612-b34e-74b6664fc089",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.0\n",
"1.0\n"
]
}
],
"source": [
"from math import sin, cos\n",
"print(sin(0))\n",
"print(cos(0))"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "65ea6cd6-a452-45d3-9274-4247e59a5ac3",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[ 5 8 13 21]\n"
]
}
],
"source": [
"import numpy as np\n",
"\n",
"a1 = np.array([5, 8, 13, 21])\n",
"print(a1)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "d6a2aa45-03bd-4e52-8f77-98bd1bb6751a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 1 3 5]\n",
" [ 8 11 14]\n",
" [18 22 26]]\n",
"int32\n",
"9\n",
"(3, 3)\n",
"14\n",
"[[ 5.2 15.6 26. ]\n",
" [ 41.6 57.2 72.8]\n",
" [ 93.6 114.4 135.2]]\n"
]
}
],
"source": [
"import numpy as np\n",
"\n",
"a1 = np.array([[1, 3, 5], [8, 11, 14], [18, 22, 26]], dtype=\"int32\")\n",
"print(a1)\n",
"# Afficher le nom du type des données du tableau\n",
"print(a1.dtype)\n",
"# Afficher le nombre de cellules au total dans le tableau\n",
"print(a1.size)\n",
"# Afficher les dimensions du tableau\n",
"print(a1.shape)\n",
"print(a1[1][2])\n",
"\n",
"# Appliquer un calcul simple à tous les éléments du tableau\n",
"a2 = a1 * 5.2\n",
"print(a2)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "c6f47454-b849-47ad-abfe-a66ca774d038",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a2 = np.arange(0, 10, 1)\n",
"a2"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "b9dca432-8fbf-4370-9917-0c8ad5e7ad38",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 34. 71.5]\n",
" [ 59. 142. ]]\n"
]
}
],
"source": [
"m1 = np.array([[5, 8], [4, 17]])\n",
"m2 = np.array([[2, 1.5], [3, 8]])\n",
"print(m1 @ m2)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.12.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

4
source/TODO.md Normal file
View File

@ -0,0 +1,4 @@
TODO :
Jointure de Dataframe
Adventure works
PRoduct Data et Sales Data

View File

@ -0,0 +1,120 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "cc5b1b45-a3dd-4f89-a731-9918a1a0366a",
"metadata": {},
"source": [
"Texte de cellule au format **Markdown**.\n",
"\n",
"Permet de documenter le carnet et de laisser des notes."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "040834c2-ab4f-456f-9cc8-8c44fdf257d6",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "09003cbc-a660-4e9a-82a3-7d66babfa235",
"metadata": {
"editable": true,
"scrolled": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [
{
"ename": "FileNotFoundError",
"evalue": "[Errno 2] No such file or directory: 'file.csv'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[11], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m df \u001b[38;5;241m=\u001b[39m \u001b[43mpd\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread_csv\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mfile.csv\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCome on\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
"File \u001b[0;32m~/Code/python/.venv/datascience/lib/python3.11/site-packages/pandas/io/parsers/readers.py:948\u001b[0m, in \u001b[0;36mread_csv\u001b[0;34m(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, date_format, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding_errors, dialect, on_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options, dtype_backend)\u001b[0m\n\u001b[1;32m 935\u001b[0m kwds_defaults \u001b[38;5;241m=\u001b[39m _refine_defaults_read(\n\u001b[1;32m 936\u001b[0m dialect,\n\u001b[1;32m 937\u001b[0m delimiter,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 944\u001b[0m dtype_backend\u001b[38;5;241m=\u001b[39mdtype_backend,\n\u001b[1;32m 945\u001b[0m )\n\u001b[1;32m 946\u001b[0m kwds\u001b[38;5;241m.\u001b[39mupdate(kwds_defaults)\n\u001b[0;32m--> 948\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_read\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfilepath_or_buffer\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkwds\u001b[49m\u001b[43m)\u001b[49m\n",
"File \u001b[0;32m~/Code/python/.venv/datascience/lib/python3.11/site-packages/pandas/io/parsers/readers.py:611\u001b[0m, in \u001b[0;36m_read\u001b[0;34m(filepath_or_buffer, kwds)\u001b[0m\n\u001b[1;32m 608\u001b[0m _validate_names(kwds\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mnames\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m))\n\u001b[1;32m 610\u001b[0m \u001b[38;5;66;03m# Create the parser.\u001b[39;00m\n\u001b[0;32m--> 611\u001b[0m parser \u001b[38;5;241m=\u001b[39m \u001b[43mTextFileReader\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfilepath_or_buffer\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwds\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 613\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m chunksize \u001b[38;5;129;01mor\u001b[39;00m iterator:\n\u001b[1;32m 614\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m parser\n",
"File \u001b[0;32m~/Code/python/.venv/datascience/lib/python3.11/site-packages/pandas/io/parsers/readers.py:1448\u001b[0m, in \u001b[0;36mTextFileReader.__init__\u001b[0;34m(self, f, engine, **kwds)\u001b[0m\n\u001b[1;32m 1445\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39moptions[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mhas_index_names\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m kwds[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mhas_index_names\u001b[39m\u001b[38;5;124m\"\u001b[39m]\n\u001b[1;32m 1447\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mhandles: IOHandles \u001b[38;5;241m|\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m-> 1448\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_engine \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_make_engine\u001b[49m\u001b[43m(\u001b[49m\u001b[43mf\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mengine\u001b[49m\u001b[43m)\u001b[49m\n",
"File \u001b[0;32m~/Code/python/.venv/datascience/lib/python3.11/site-packages/pandas/io/parsers/readers.py:1705\u001b[0m, in \u001b[0;36mTextFileReader._make_engine\u001b[0;34m(self, f, engine)\u001b[0m\n\u001b[1;32m 1703\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mb\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m mode:\n\u001b[1;32m 1704\u001b[0m mode \u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mb\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m-> 1705\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mhandles \u001b[38;5;241m=\u001b[39m \u001b[43mget_handle\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 1706\u001b[0m \u001b[43m \u001b[49m\u001b[43mf\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1707\u001b[0m \u001b[43m \u001b[49m\u001b[43mmode\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1708\u001b[0m \u001b[43m \u001b[49m\u001b[43mencoding\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43moptions\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mencoding\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1709\u001b[0m \u001b[43m \u001b[49m\u001b[43mcompression\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43moptions\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mcompression\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1710\u001b[0m \u001b[43m \u001b[49m\u001b[43mmemory_map\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43moptions\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mmemory_map\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1711\u001b[0m \u001b[43m \u001b[49m\u001b[43mis_text\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mis_text\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1712\u001b[0m \u001b[43m \u001b[49m\u001b[43merrors\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43moptions\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mencoding_errors\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mstrict\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1713\u001b[0m \u001b[43m \u001b[49m\u001b[43mstorage_options\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43moptions\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mstorage_options\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1714\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1715\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mhandles \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m 1716\u001b[0m f \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mhandles\u001b[38;5;241m.\u001b[39mhandle\n",
"File \u001b[0;32m~/Code/python/.venv/datascience/lib/python3.11/site-packages/pandas/io/common.py:863\u001b[0m, in \u001b[0;36mget_handle\u001b[0;34m(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)\u001b[0m\n\u001b[1;32m 858\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(handle, \u001b[38;5;28mstr\u001b[39m):\n\u001b[1;32m 859\u001b[0m \u001b[38;5;66;03m# Check whether the filename is to be opened in binary mode.\u001b[39;00m\n\u001b[1;32m 860\u001b[0m \u001b[38;5;66;03m# Binary mode does not support 'encoding' and 'newline'.\u001b[39;00m\n\u001b[1;32m 861\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m ioargs\u001b[38;5;241m.\u001b[39mencoding \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mb\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m ioargs\u001b[38;5;241m.\u001b[39mmode:\n\u001b[1;32m 862\u001b[0m \u001b[38;5;66;03m# Encoding\u001b[39;00m\n\u001b[0;32m--> 863\u001b[0m handle \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mopen\u001b[39m(\n\u001b[1;32m 864\u001b[0m handle,\n\u001b[1;32m 865\u001b[0m ioargs\u001b[38;5;241m.\u001b[39mmode,\n\u001b[1;32m 866\u001b[0m encoding\u001b[38;5;241m=\u001b[39mioargs\u001b[38;5;241m.\u001b[39mencoding,\n\u001b[1;32m 867\u001b[0m errors\u001b[38;5;241m=\u001b[39merrors,\n\u001b[1;32m 868\u001b[0m newline\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 869\u001b[0m )\n\u001b[1;32m 870\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 871\u001b[0m \u001b[38;5;66;03m# Binary mode\u001b[39;00m\n\u001b[1;32m 872\u001b[0m handle \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mopen\u001b[39m(handle, ioargs\u001b[38;5;241m.\u001b[39mmode)\n",
"\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: 'file.csv'"
]
}
],
"source": [
"df = pd.read_csv(\"file.csv\")\n",
"print(\"Come on\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a372749f-4b26-4e36-8a1e-627c50a274f2",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "59e5f06b-654c-47ce-a8f0-0e062726d913",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "586b204b-85ae-496f-849f-d8fc943f048e",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "2060d594-1231-4a97-a7ea-b86365ebefcf",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "44badf67-dc1e-4d81-8ab3-2af13d310be0",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@ -0,0 +1,130 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "initial_id",
"metadata": {
"collapsed": true,
"ExecuteTime": {
"end_time": "2023-11-03T14:40:42.068348908Z",
"start_time": "2023-11-03T14:40:41.997684480Z"
}
},
"outputs": [],
"source": [
"import numpy as np"
]
},
{
"cell_type": "markdown",
"source": [
"## Générer des séquences avec Numpy"
],
"metadata": {
"collapsed": false
},
"id": "6d65456282534466"
},
{
"cell_type": "markdown",
"source": [
"### Tableaux de nombres aléatoires"
],
"metadata": {
"collapsed": false
},
"id": "adb17684a78c829f"
},
{
"cell_type": "code",
"execution_count": 6,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 6.35623608 0.72967602 2.5754436 ]\n",
" [-2.88764467 -1.78055093 2.04930599]\n",
" [ 8.1408593 9.88370176 13.06873958]\n",
" [12.10708755 9.83391867 1.11422918]\n",
" [ 1.93749749 8.25277919 12.33940067]\n",
" [ 9.29587924 10.28278442 7.00934509]\n",
" [10.95330272 2.24590563 2.6462974 ]\n",
" [ 7.82980317 10.88657225 6.50770094]]\n"
]
}
],
"source": [
"import numpy as np\n",
"normal1 = np.random.normal(scale=5.0, loc=5.0, size=(8, 3)) # loi Gaussienne, 3x3, de 0 à 10.0\n",
"print(normal1)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-11-03T14:44:17.624267987Z",
"start_time": "2023-11-03T14:44:17.582546621Z"
}
},
"id": "7790b82b0805c928"
},
{
"cell_type": "code",
"execution_count": 10,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1.14733876 4.66776332 0.07763899 0.41786323 4.55656594 2.6577\n",
" 0.08228448 0.47885595 7.58314882 0.12093808]\n"
]
}
],
"source": [
"pareto1 = np.random.pareto(1.0, size=10)\n",
"print(pareto1)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-11-03T15:00:09.010119456Z",
"start_time": "2023-11-03T15:00:08.985865113Z"
}
},
"id": "423db763dfe8266e"
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [],
"metadata": {
"collapsed": false
},
"id": "9efd8f9a713c156a"
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@ -0,0 +1,21 @@
from concurrent.futures import ThreadPoolExecutor
from pathlib import Path
import pandas as pd
def process_file(name: Path):
"""Afficher les informations concernant un fichier .xlsx."""
dataframe = pd.read_excel(name)
print(f"{name.name:>30} : {len(dataframe)} enregistrements.")
if __name__ == '__main__':
# Parcourir les fichiers du projet à la recherche de fichiers XLSX
# Définir le chemin de départ à celui du projet (contenant le fichier requirements.txt)
path = Path(__file__)
while not (path / "requirements.txt").exists():
path = path.parent
# Parcourir tous les fichiers .xlsx récursivement
executor = ThreadPoolExecutor(max_workers=8)
futures = []
for result in path.rglob("*.xlsx"):
futures.append(executor.submit(process_file, result))

Binary file not shown.

View File

@ -0,0 +1,12 @@
import pandas as pd
if __name__ == '__main__':
df = pd.DataFrame({
'country': ['fra', 'fra', 'fra', 'fra', 'bel', 'bel', 'bel', "bel"],
'district': ['north', 'east', 'west', 'south', 'north', 'east', 'west', 'south'],
'population': [10_000, 30_000, 50_000, 70_000, 20_000, 40_000, 60_000, 80_000],
'extra': ['h', 'i', 'j', 'k', 'l', 'm', 'n', 'o']
})
df2 = df.pivot_table(values=["population"], index="district", columns="country", aggfunc="count")
print(df2.to_string())
print(df2.columns)

View File

@ -0,0 +1,36 @@
import pandas as pd
from matplotlib import pyplot as plt
import matplotlib
if __name__ == '__main__':
# Configure Pandas to only display floats not in scientific notation
pd.options.display.float_format = "{:.2f}".format
# Read a list of FR lowest administrative divisions
# See france-communes-readme.md for field informations
df = pd.read_json("../data/json/france-communes.json")
# Get the mean of columns as a new row, and only keep the population column
df1 = df.copy()
df1.loc["mean"] = df1.mean(skipna=True, numeric_only=True)[["population"]]
# Show dataframe
print(df1.to_string(max_cols=9))
# Get only cities in the dept 94
df2: pd.DataFrame = df.copy()
# Filter rows by using criteria
df2 = df2.loc[(df2["departement"] == "94") & (df2["population"] > 0) & (df2["nom"].str.contains(""))]
# Sort data by columns
df2.sort_values("nom", inplace=True)
# Remove columns from the dataframe
df2.drop(columns=["chefLieu", "commune"], inplace=True)
print(df2.to_string(max_cols=10))
# Show lines
matplotlib.use("QtCairo")
plt.rcParams["figure.dpi"] = 96
gp = df2.plot.line(x="nom", y="population")
plt.show()
# Get postal codes from line 37237
row = df2.loc[37237]
print(row["codesPostaux"], type(row["codesPostaux"]))

View File

@ -0,0 +1,10 @@
import sqlite3
import pandas as pd
if __name__ == '__main__':
connection = sqlite3.connect("../data/people.sqlite")
df = pd.read_sql("SELECT * FROM person", connection)
connection.close()
print(df)

View File

@ -0,0 +1,11 @@
"""Define simple Series objects by hand."""
import pandas as pd
if __name__ == '__main__':
# Creating a series with coherent value type
s1 = pd.Series([1, 3, 7, 9, 13, 15, 19, 21])
# Get the length of the series
print(f"Size of the series: {len(s1)}")
# Display the contents of s1
print(s1)

View File

@ -0,0 +1,35 @@
"""Define simple DataFrame objects by hand."""
import pandas as pd
if __name__ == '__main__':
# Creating a series with coherent value type
df1 = pd.DataFrame({"age": [25, 45, 65], "prenom": ["Pierre", "Paul", "Jacques"]})
# Get the column names of the dataframe
print("Columns:", df1.columns.tolist())
# Get the number of rows in the dataframe
print(f"Size of the dataframe in rows: {len(df1)}")
# Show the type of the columns
print("Data type of columns (autodetected):")
type_dict = df1.dtypes.to_dict()
for column, dtype in type_dict.items():
print(f"{column:<20} : {str(dtype):<20}")
print("_" * 80)
# Display the contents of the dataframe
print(df1)
# Creating a series with coherent value type
df2 = pd.DataFrame([[25, "Pierre"], [45, "Paul"], [65, "Jacques"]])
# Get the column names of the dataframe
print("Columns:", df2.columns.tolist())
# Get the number of rows in the dataframe
print(f"Size of the dataframe in rows: {len(df2)}")
# Show the type of the columns
print("Data type of columns (autodetected):")
type_dict = df2.dtypes.to_dict()
for column, dtype in type_dict.items():
print(f"{column:<20} : {str(dtype):<20}")
print("_" * 80)
# Display the contents of the dataframe
print(df2)

View File

@ -0,0 +1,27 @@
"""
Create a DataFrame and use indexes to
"""
import pandas as pd
# Create a dataframe and associate an index to it
df = pd.DataFrame(
data={"name": ["Mac", "Ann", "Rob"], "age": [33, 44, 55]},
index=["u1", "u2", "u3"] # as many values as rows
)
# Show normal DataFrame
print(df)
# Access one row using an index value
print(df.loc["u1"])
# Access the same row using a numerical index
print(df.iloc[0])
# Get a DataFrame with a selection of lines
# To extract this, the selection of lines **must** be a list and not a tuple;
# the tuple is used to select or slice in the other axis.
print(df.loc[["u1", "u3", "u2"]])
# Show the index0
print(df.index)

View File

@ -0,0 +1,21 @@
"""
Read an online CSV file into a DataFrame.
Since the referenced file contains a datetime column, and by default
read_csv does not interpret data from the text file, you have to replace
some columns with their conversion as a correct dtype.
Or better, you can directly tell the read_csv function to interpret
"""
import pandas as pd
url = "https://media.githubusercontent.com/media/datablist/sample-csv-files/main/files/customers/customers-100.csv"
df = pd.read_csv(url, parse_dates=["Subscription Date"])
print(df.to_string(max_cols=7))
print(df.dtypes)
# Remplacer une colonne avec une conversionl
df["Subscription Date"] = pd.to_datetime(df["Subscription Date"])
print(df, df.dtypes)

View File

@ -0,0 +1,14 @@
import pandas as pd
if __name__ == '__main__':
df = pd.Series([1, 3, 2, 4, 2, 2, 2, 1, 1, 3])
# Add an index to the series, that could be used to make a
# temporal series.
df.index = pd.Series([2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
print(df)
s = pd.Series([2, 5, 2, 6], index=pd.date_range("2023-01-01", "2023-01-10", 4))
print(s)
dr = pd.date_range("2023-01-01", "2023-01-10", 4)
print(dr)

View File

@ -0,0 +1,22 @@
import pandas as pd
# Create a Pandas dataframe from the data.
df = pd.DataFrame([10, 20, 30, 20, 15, 30, 45])
# Create a Pandas Excel writer using XlsxWriter as the engine.
writer = pd.ExcelWriter('chart-demo.xlsx', engine='xlsxwriter')
df.to_excel(writer, sheet_name='Sheet1')
# Close the Pandas Excel writer and output the Excel file.
# Get the workbook for the writer
workbook: pd.ExcelWriter = writer.book
worksheet = writer.sheets['Sheet1']
chart = workbook.add_chart({"type": "column"})
# Configure the series of the chart from the dataframe data.
chart.add_series({'values': '=Sheet1!$B$2:$B$8'})
# Insert the chart into the worksheet.
worksheet.insert_chart('D2', chart)
writer.close()

Binary file not shown.

View File

@ -0,0 +1,12 @@
import pandas as pd
from matplotlib import pyplot
from matplotlib.axes import Axes
df = pd.read_excel("sample-data-food-sales.xlsx", sheet_name="FoodSales")
groups = df.groupby(["Region", "City"])
averages = groups.mean(numeric_only=True)
axis: Axes = averages.plot.bar(rot=0)
for p in axis.patches:
axis.annotate(f"{p.get_height():.1f}", (p.get_x() + 0.05, p.get_height() + 5), rotation=90)
pyplot.show()

Binary file not shown.

View File

@ -0,0 +1,8 @@
import pandas as pd
from pandas import DataFrame
def get_dataframe(name: str = None) -> DataFrame:
"""Load a dataframe from a CSV file in the data folder."""
data = pd.read_csv(f"data/{name or 'heights'}.csv")
return data

View File

@ -0,0 +1,24 @@
# Fichiers de données
## `sample-data-food-sales.xlsx`
Complexité : `basse`
Traitements envisageables :
- Gestion des dates
- Gestion des feuilles de calcul
- Groupements
- Tri, Calculs statistiques, Filtres
- Tableaux croisés
- Affichage de graphiques (facettes)
- Calculs simples (ex. quantités + prix unitaire... déjà calculé)
## `adventure-works-sales.xlsx`
Complexité : `haute` (nombreuses feuilles)
Traitements possibles :
- Jointures (gauche, droite, externe, interne)
- Groupements
- Tri, Calculs statistiques, Filtres
TODO: Charger un CSV avec une colonne de dates (peut-être une conversion depuis un fichier XL)

View File

@ -0,0 +1,100 @@
1,"Eldon Base for stackable storage shelf, platinum",Muhammed MacIntyre,3,-213.25,38.94,35,Nunavut,Storage & Organization,0.8
2,"1.7 Cubic Foot Compact ""Cube"" Office Refrigerators",Barry French,293,457.81,208.16,68.02,Nunavut,Appliances,0.58
3,"Cardinal Slant-D<> Ring Binder, Heavy Gauge Vinyl",Barry French,293,46.71,8.69,2.99,Nunavut,Binders and Binder Accessories,0.39
4,R380,Clay Rozendal,483,1198.97,195.99,3.99,Nunavut,Telephones and Communication,0.58
5,Holmes HEPA Air Purifier,Carlos Soltero,515,30.94,21.78,5.94,Nunavut,Appliances,0.5
6,G.E. Longer-Life Indoor Recessed Floodlight Bulbs,Carlos Soltero,515,4.43,6.64,4.95,Nunavut,Office Furnishings,0.37
7,"Angle-D Binders with Locking Rings, Label Holders",Carl Jackson,613,-54.04,7.3,7.72,Nunavut,Binders and Binder Accessories,0.38
8,"SAFCO Mobile Desk Side File, Wire Frame",Carl Jackson,613,127.70,42.76,6.22,Nunavut,Storage & Organization,
9,"SAFCO Commercial Wire Shelving, Black",Monica Federle,643,-695.26,138.14,35,Nunavut,Storage & Organization,
10,Xerox 198,Dorothy Badders,678,-226.36,4.98,8.33,Nunavut,Paper,0.38
11,Xerox 1980,Neola Schneider,807,-166.85,4.28,6.18,Nunavut,Paper,0.4
12,Advantus Map Pennant Flags and Round Head Tacks,Neola Schneider,807,-14.33,3.95,2,Nunavut,Rubber Bands,0.53
13,Holmes HEPA Air Purifier,Carlos Daly,868,134.72,21.78,5.94,Nunavut,Appliances,0.5
14,"DS/HD IBM Formatted Diskettes, 200/Pack - Staples",Carlos Daly,868,114.46,47.98,3.61,Nunavut,Computer Peripherals,0.71
15,"Wilson Jones 1"" Hanging DublLock<63> Ring Binders",Claudia Miner,933,-4.72,5.28,2.99,Nunavut,Binders and Binder Accessories,0.37
16,Ultra Commercial Grade Dual Valve Door Closer,Neola Schneider,995,782.91,39.89,3.04,Nunavut,Office Furnishings,0.53
17,"#10-4 1/8"" x 9 1/2"" Premium Diagonal Seam Envelopes",Allen Rosenblatt,998,93.80,15.74,1.39,Nunavut,Envelopes,0.4
18,Hon 4-Shelf Metal Bookcases,Sylvia Foulston,1154,440.72,100.98,26.22,Nunavut,Bookcases,0.6
19,"Lesro Sheffield Collection Coffee Table, End Table, Center Table, Corner Table",Sylvia Foulston,1154,-481.04,71.37,69,Nunavut,Tables,0.68
20,g520,Jim Radford,1344,-11.68,65.99,5.26,Nunavut,Telephones and Communication,0.59
21,LX 788,Jim Radford,1344,313.58,155.99,8.99,Nunavut,Telephones and Communication,0.58
22,Avery 52,Carlos Soltero,1412,26.92,3.69,0.5,Nunavut,Labels,0.38
23,Plymouth Boxed Rubber Bands by Plymouth,Carlos Soltero,1412,-5.77,4.71,0.7,Nunavut,Rubber Bands,0.8
24,"GBC Pre-Punched Binding Paper, Plastic, White, 8-1/2"" x 11""",Carl Ludwig,1539,-172.88,15.99,13.18,Nunavut,Binders and Binder Accessories,0.37
25,"Maxell 3.5"" DS/HD IBM-Formatted Diskettes, 10/Pack",Carl Ludwig,1539,-144.55,4.89,4.93,Nunavut,Computer Peripherals,0.66
26,Newell 335,Don Miller,1540,5.76,2.88,0.7,Nunavut,Pens & Art Supplies,0.56
27,SANFORD Liquid Accent<6E> Tank-Style Highlighters,Annie Cyprus,1702,4.90,2.84,0.93,Nunavut,Pens & Art Supplies,0.54
28,Canon PC940 Copier,Carl Ludwig,1761,-547.61,449.99,49,Nunavut,Copiers and Fax,0.38
29,"Tenex Personal Project File with Scoop Front Design, Black",Carlos Soltero,1792,-5.45,13.48,4.51,Nunavut,Storage & Organization,0.59
30,Col-Erase<73> Pencils with Erasers,Grant Carroll,2275,41.67,6.08,1.17,Nunavut,Pens & Art Supplies,0.56
31,"Imation 3.5"" DS/HD IBM Formatted Diskettes, 10/Pack",Don Miller,2277,-46.03,5.98,4.38,Nunavut,Computer Peripherals,0.75
32,"White Dual Perf Computer Printout Paper, 2700 Sheets, 1 Part, Heavyweight, 20 lbs., 14 7/8 x 11",Don Miller,2277,33.67,40.99,19.99,Nunavut,Paper,0.36
33,Self-Adhesive Address Labels for Typewriters by Universal,Alan Barnes,2532,140.01,7.31,0.49,Nunavut,Labels,0.38
34,Accessory37,Alan Barnes,2532,-78.96,20.99,2.5,Nunavut,Telephones and Communication,0.81
35,Fuji 5.2GB DVD-RAM,Jack Garza,2631,252.66,40.96,1.99,Nunavut,Computer Peripherals,0.55
36,Bevis Steel Folding Chairs,Julia West,2757,-1766.01,95.95,74.35,Nunavut,Chairs & Chairmats,0.57
37,Avery Binder Labels,Eugene Barchas,2791,-236.27,3.89,7.01,Nunavut,Binders and Binder Accessories,0.37
38,Hon Every-Day<61> Chair Series Swivel Task Chairs,Eugene Barchas,2791,80.44,120.98,30,Nunavut,Chairs & Chairmats,0.64
39,"IBM Multi-Purpose Copy Paper, 8 1/2 x 11"", Case",Eugene Barchas,2791,118.94,30.98,5.76,Nunavut,Paper,0.4
40,Global Troy<6F> Executive Leather Low-Back Tilter,Edward Hooks,2976,3424.22,500.98,26,Nunavut,Chairs & Chairmats,0.6
41,XtraLife<EFBFBD> ClearVue<75> Slant-D<> Ring Binders by Cardinal,Brad Eason,3232,-11.83,7.84,4.71,Nunavut,Binders and Binder Accessories,0.35
42,Computer Printout Paper with Letter-Trim Perforations,Nicole Hansen,3524,52.35,18.97,9.03,Nunavut,Paper,0.37
43,6160,Dorothy Wardle,3908,-180.20,115.99,2.5,Nunavut,Telephones and Communication,0.57
44,Avery 49,Aaron Bergman,4132,1.32,2.88,0.5,Nunavut,Labels,0.36
45,Hoover Portapower<65> Portable Vacuum,Jim Radford,4612,-375.64,4.48,49,Nunavut,Appliances,0.6
46,Timeport L7089,Annie Cyprus,4676,-104.25,125.99,7.69,Nunavut,Telephones and Communication,0.58
47,Avery 510,Annie Cyprus,4676,85.96,3.75,0.5,Nunavut,Labels,0.37
48,Xerox 1881,Annie Cyprus,4676,-8.38,12.28,6.47,Nunavut,Paper,0.38
49,LX 788,Annie Cyprus,4676,1115.69,155.99,8.99,Nunavut,Telephones and Communication,0.58
50,"Cardinal Slant-D<> Ring Binder, Heavy Gauge Vinyl",Annie Cyprus,5284,-3.05,8.69,2.99,Nunavut,Binders and Binder Accessories,0.39
51,"Memorex 4.7GB DVD-RAM, 3/Pack",Clay Rozendal,5316,514.07,31.78,1.99,Nunavut,Computer Peripherals,0.42
52,Unpadded Memo Slips,Don Jones,5409,-7.04,3.98,2.97,Nunavut,Paper,0.35
53,"Adams Telephone Message Book W/Dividers/Space For Phone Numbers, 5 1/4""X8 1/2"", 300/Messages",Beth Thompson,5506,4.41,5.88,3.04,Nunavut,Paper,0.36
54,"Eldon Expressions<6E> Desk Accessory, Wood Pencil Holder, Oak",Frank Price,5569,-0.06,9.65,6.22,Nunavut,Office Furnishings,0.55
55,Bell Sonecor JB700 Caller ID,Michelle Lonsdale,5607,-50.33,7.99,5.03,Nunavut,Telephones and Communication,0.6
56,Avery Arch Ring Binders,Ann Chong,5894,87.68,58.1,1.49,Nunavut,Binders and Binder Accessories,0.38
57,APC 7 Outlet Network SurgeArrest Surge Protector,Ann Chong,5894,-68.22,80.48,4.5,Nunavut,Appliances,0.55
58,"Deflect-o RollaMat Studded, Beveled Mat for Medium Pile Carpeting",Joy Bell,5925,-354.90,92.23,39.61,Nunavut,Office Furnishings,0.67
59,Accessory4,Joy Bell,5925,-267.01,85.99,0.99,Nunavut,Telephones and Communication,0.85
60,Personal Creations<6E> Ink Jet Cards and Labels,Skye Norling,6016,3.63,11.48,5.43,Nunavut,Paper,0.36
61,High Speed Automatic Electric Letter Opener,Barry Weirich,6116,-1759.58,1637.53,24.49,Nunavut,"Scissors, Rulers and Trimmers",0.81
62,Xerox 1966,Grant Carroll,6182,-116.79,6.48,6.65,Nunavut,Paper,0.36
63,Xerox 213,Grant Carroll,6182,-67.28,6.48,7.86,Nunavut,Paper,0.37
64,"Boston Electric Pencil Sharpener, Model 1818, Charcoal Black",Adrian Hane,6535,-19.33,28.15,8.99,Nunavut,Pens & Art Supplies,0.57
65,Hammermill CopyPlus Copy Paper (20Lb. and 84 Bright),Skye Norling,6884,-61.21,4.98,4.75,Nunavut,Paper,0.36
66,"Telephone Message Books with Fax/Mobile Section, 5 1/2"" x 3 3/16""",Skye Norling,6884,119.09,6.35,1.02,Nunavut,Paper,0.39
67,Crate-A-Files<65>,Andrew Gjertsen,6916,-141.27,10.9,7.46,Nunavut,Storage & Organization,0.59
68,"Angle-D Binders with Locking Rings, Label Holders",Ralph Knight,6980,-77.28,7.3,7.72,Nunavut,Binders and Binder Accessories,0.38
69,"80 Minute CD-R Spindle, 100/Pack - Staples",Dorothy Wardle,6982,407.44,39.48,1.99,Nunavut,Computer Peripherals,0.54
70,"Bush Westfield Collection Bookcases, Dark Cherry Finish, Fully Assembled",Dorothy Wardle,6982,-338.27,100.98,57.38,Nunavut,Bookcases,0.78
71,12-1/2 Diameter Round Wall Clock,Dorothy Wardle,6982,52.56,19.98,10.49,Nunavut,Office Furnishings,0.49
72,SAFCO Arco Folding Chair,Grant Carroll,7110,1902.24,276.2,24.49,Nunavut,Chairs & Chairmats,
73,"#10 White Business Envelopes,4 1/8 x 9 1/2",Barry Weirich,7430,353.20,15.67,1.39,Nunavut,Envelopes,0.38
74,3M Office Air Cleaner,Beth Paige,7906,271.78,25.98,5.37,Nunavut,Appliances,0.5
75,"Global Leather and Oak Executive Chair, Black",Sylvia Foulston,8391,-268.36,300.98,64.73,Nunavut,Chairs & Chairmats,0.56
76,Xerox 1936,Nicole Hansen,8419,70.39,19.98,5.97,Nunavut,Paper,0.38
77,Xerox 214,Nicole Hansen,8419,-86.62,6.48,7.03,Nunavut,Paper,0.37
78,Carina Double Wide Media Storage Towers in Natural & Black,Nicole Hansen,8833,-846.73,80.98,35,Nunavut,Storage & Organization,0.81
79,Staples<EFBFBD> General Use 3-Ring Binders,Beth Paige,8995,8.05,1.88,1.49,Nunavut,Binders and Binder Accessories,0.37
80,Xerox 1904,Beth Paige,8995,-78.02,6.48,5.86,Northwest Territories,Paper,0.36
81,Luxo Professional Combination Clamp-On Lamps,Beth Paige,8995,737.94,102.3,21.26,Northwest Territories,Office Furnishings,0.59
82,Xerox 217,Beth Paige,8995,-191.28,6.48,8.19,Northwest Territories,Paper,0.37
83,Revere Boxed Rubber Bands by Revere,Beth Paige,8995,-21.49,1.89,0.76,Northwest Territories,Rubber Bands,0.83
84,"Acco Smartsocket<65> Table Surge Protector, 6 Color-Coded Adapter Outlets",Sylvia Foulston,9126,884.08,62.05,3.99,Northwest Territories,Appliances,0.55
85,"Tennsco Snap-Together Open Shelving Units, Starter Sets and Add-On Units",Bryan Davis,9127,-329.49,279.48,35,Northwest Territories,Storage & Organization,0.8
86,Hon 4070 Series Pagoda<64> Round Back Stacking Chairs,Joy Bell,9509,2825.15,320.98,58.95,Northwest Territories,Chairs & Chairmats,0.57
87,Xerox 1887,Joy Bell,9509,2.13,18.97,5.21,Northwest Territories,Paper,0.37
88,Xerox 1891,Joy Bell,9509,707.15,48.91,5.81,Northwest Territories,Paper,0.38
89,Avery 506,Alan Barnes,9763,75.13,4.13,0.5,Northwest Territories,Labels,0.39
90,"Bush Heritage Pine Collection 5-Shelf Bookcase, Albany Pine Finish, *Special Order",Grant Carroll,9927,-270.63,140.98,53.48,Northwest Territories,Bookcases,0.65
91,"Lifetime Advantage<67> Folding Chairs, 4/Carton",Grant Carroll,9927,3387.35,218.08,18.06,Northwest Territories,Chairs & Chairmats,0.57
92,Microsoft Natural Multimedia Keyboard,Grant Carroll,9927,-82.16,50.98,6.5,Northwest Territories,Computer Peripherals,0.73
93,"Staples Wirebound Steno Books, 6"" x 9"", 12/Pack",Delfina Latchford,10022,-3.88,10.14,2.27,Northwest Territories,Paper,0.36
94,"GBC Pre-Punched Binding Paper, Plastic, White, 8-1/2"" x 11""",Don Jones,10437,-191.22,15.99,13.18,Northwest Territories,Binders and Binder Accessories,0.37
95,Bevis Boat-Shaped Conference Table,Doug Bickford,10499,31.21,262.11,62.74,Northwest Territories,Tables,0.75
96,"Linden<EFBFBD> 12"" Wall Clock With Oak Frame",Doug Bickford,10535,-44.14,33.98,19.99,Northwest Territories,Office Furnishings,0.55
97,Newell 326,Doug Bickford,10535,-0.79,1.76,0.7,Northwest Territories,Pens & Art Supplies,0.56
98,Prismacolor Color Pencil Set,Jamie Kunitz,10789,76.42,19.84,4.1,Northwest Territories,Pens & Art Supplies,0.44
99,Xerox Blank Computer Paper,Anthony Johnson,10791,93.36,19.98,5.77,Northwest Territories,Paper,0.38
100,600 Series Flip,Ralph Knight,10945,4.22,95.99,8.99,Northwest Territories,Telephones and Communication,0.57
1 1 Eldon Base for stackable storage shelf, platinum Muhammed MacIntyre 3 -213.25 38.94 35 Nunavut Storage & Organization 0.8
2 2 1.7 Cubic Foot Compact "Cube" Office Refrigerators Barry French 293 457.81 208.16 68.02 Nunavut Appliances 0.58
3 3 Cardinal Slant-D® Ring Binder, Heavy Gauge Vinyl Barry French 293 46.71 8.69 2.99 Nunavut Binders and Binder Accessories 0.39
4 4 R380 Clay Rozendal 483 1198.97 195.99 3.99 Nunavut Telephones and Communication 0.58
5 5 Holmes HEPA Air Purifier Carlos Soltero 515 30.94 21.78 5.94 Nunavut Appliances 0.5
6 6 G.E. Longer-Life Indoor Recessed Floodlight Bulbs Carlos Soltero 515 4.43 6.64 4.95 Nunavut Office Furnishings 0.37
7 7 Angle-D Binders with Locking Rings, Label Holders Carl Jackson 613 -54.04 7.3 7.72 Nunavut Binders and Binder Accessories 0.38
8 8 SAFCO Mobile Desk Side File, Wire Frame Carl Jackson 613 127.70 42.76 6.22 Nunavut Storage & Organization
9 9 SAFCO Commercial Wire Shelving, Black Monica Federle 643 -695.26 138.14 35 Nunavut Storage & Organization
10 10 Xerox 198 Dorothy Badders 678 -226.36 4.98 8.33 Nunavut Paper 0.38
11 11 Xerox 1980 Neola Schneider 807 -166.85 4.28 6.18 Nunavut Paper 0.4
12 12 Advantus Map Pennant Flags and Round Head Tacks Neola Schneider 807 -14.33 3.95 2 Nunavut Rubber Bands 0.53
13 13 Holmes HEPA Air Purifier Carlos Daly 868 134.72 21.78 5.94 Nunavut Appliances 0.5
14 14 DS/HD IBM Formatted Diskettes, 200/Pack - Staples Carlos Daly 868 114.46 47.98 3.61 Nunavut Computer Peripherals 0.71
15 15 Wilson Jones 1" Hanging DublLock® Ring Binders Claudia Miner 933 -4.72 5.28 2.99 Nunavut Binders and Binder Accessories 0.37
16 16 Ultra Commercial Grade Dual Valve Door Closer Neola Schneider 995 782.91 39.89 3.04 Nunavut Office Furnishings 0.53
17 17 #10-4 1/8" x 9 1/2" Premium Diagonal Seam Envelopes Allen Rosenblatt 998 93.80 15.74 1.39 Nunavut Envelopes 0.4
18 18 Hon 4-Shelf Metal Bookcases Sylvia Foulston 1154 440.72 100.98 26.22 Nunavut Bookcases 0.6
19 19 Lesro Sheffield Collection Coffee Table, End Table, Center Table, Corner Table Sylvia Foulston 1154 -481.04 71.37 69 Nunavut Tables 0.68
20 20 g520 Jim Radford 1344 -11.68 65.99 5.26 Nunavut Telephones and Communication 0.59
21 21 LX 788 Jim Radford 1344 313.58 155.99 8.99 Nunavut Telephones and Communication 0.58
22 22 Avery 52 Carlos Soltero 1412 26.92 3.69 0.5 Nunavut Labels 0.38
23 23 Plymouth Boxed Rubber Bands by Plymouth Carlos Soltero 1412 -5.77 4.71 0.7 Nunavut Rubber Bands 0.8
24 24 GBC Pre-Punched Binding Paper, Plastic, White, 8-1/2" x 11" Carl Ludwig 1539 -172.88 15.99 13.18 Nunavut Binders and Binder Accessories 0.37
25 25 Maxell 3.5" DS/HD IBM-Formatted Diskettes, 10/Pack Carl Ludwig 1539 -144.55 4.89 4.93 Nunavut Computer Peripherals 0.66
26 26 Newell 335 Don Miller 1540 5.76 2.88 0.7 Nunavut Pens & Art Supplies 0.56
27 27 SANFORD Liquid Accent™ Tank-Style Highlighters Annie Cyprus 1702 4.90 2.84 0.93 Nunavut Pens & Art Supplies 0.54
28 28 Canon PC940 Copier Carl Ludwig 1761 -547.61 449.99 49 Nunavut Copiers and Fax 0.38
29 29 Tenex Personal Project File with Scoop Front Design, Black Carlos Soltero 1792 -5.45 13.48 4.51 Nunavut Storage & Organization 0.59
30 30 Col-Erase® Pencils with Erasers Grant Carroll 2275 41.67 6.08 1.17 Nunavut Pens & Art Supplies 0.56
31 31 Imation 3.5" DS/HD IBM Formatted Diskettes, 10/Pack Don Miller 2277 -46.03 5.98 4.38 Nunavut Computer Peripherals 0.75
32 32 White Dual Perf Computer Printout Paper, 2700 Sheets, 1 Part, Heavyweight, 20 lbs., 14 7/8 x 11 Don Miller 2277 33.67 40.99 19.99 Nunavut Paper 0.36
33 33 Self-Adhesive Address Labels for Typewriters by Universal Alan Barnes 2532 140.01 7.31 0.49 Nunavut Labels 0.38
34 34 Accessory37 Alan Barnes 2532 -78.96 20.99 2.5 Nunavut Telephones and Communication 0.81
35 35 Fuji 5.2GB DVD-RAM Jack Garza 2631 252.66 40.96 1.99 Nunavut Computer Peripherals 0.55
36 36 Bevis Steel Folding Chairs Julia West 2757 -1766.01 95.95 74.35 Nunavut Chairs & Chairmats 0.57
37 37 Avery Binder Labels Eugene Barchas 2791 -236.27 3.89 7.01 Nunavut Binders and Binder Accessories 0.37
38 38 Hon Every-Day® Chair Series Swivel Task Chairs Eugene Barchas 2791 80.44 120.98 30 Nunavut Chairs & Chairmats 0.64
39 39 IBM Multi-Purpose Copy Paper, 8 1/2 x 11", Case Eugene Barchas 2791 118.94 30.98 5.76 Nunavut Paper 0.4
40 40 Global Troy™ Executive Leather Low-Back Tilter Edward Hooks 2976 3424.22 500.98 26 Nunavut Chairs & Chairmats 0.6
41 41 XtraLife® ClearVue™ Slant-D® Ring Binders by Cardinal Brad Eason 3232 -11.83 7.84 4.71 Nunavut Binders and Binder Accessories 0.35
42 42 Computer Printout Paper with Letter-Trim Perforations Nicole Hansen 3524 52.35 18.97 9.03 Nunavut Paper 0.37
43 43 6160 Dorothy Wardle 3908 -180.20 115.99 2.5 Nunavut Telephones and Communication 0.57
44 44 Avery 49 Aaron Bergman 4132 1.32 2.88 0.5 Nunavut Labels 0.36
45 45 Hoover Portapower™ Portable Vacuum Jim Radford 4612 -375.64 4.48 49 Nunavut Appliances 0.6
46 46 Timeport L7089 Annie Cyprus 4676 -104.25 125.99 7.69 Nunavut Telephones and Communication 0.58
47 47 Avery 510 Annie Cyprus 4676 85.96 3.75 0.5 Nunavut Labels 0.37
48 48 Xerox 1881 Annie Cyprus 4676 -8.38 12.28 6.47 Nunavut Paper 0.38
49 49 LX 788 Annie Cyprus 4676 1115.69 155.99 8.99 Nunavut Telephones and Communication 0.58
50 50 Cardinal Slant-D® Ring Binder, Heavy Gauge Vinyl Annie Cyprus 5284 -3.05 8.69 2.99 Nunavut Binders and Binder Accessories 0.39
51 51 Memorex 4.7GB DVD-RAM, 3/Pack Clay Rozendal 5316 514.07 31.78 1.99 Nunavut Computer Peripherals 0.42
52 52 Unpadded Memo Slips Don Jones 5409 -7.04 3.98 2.97 Nunavut Paper 0.35
53 53 Adams Telephone Message Book W/Dividers/Space For Phone Numbers, 5 1/4"X8 1/2", 300/Messages Beth Thompson 5506 4.41 5.88 3.04 Nunavut Paper 0.36
54 54 Eldon Expressions™ Desk Accessory, Wood Pencil Holder, Oak Frank Price 5569 -0.06 9.65 6.22 Nunavut Office Furnishings 0.55
55 55 Bell Sonecor JB700 Caller ID Michelle Lonsdale 5607 -50.33 7.99 5.03 Nunavut Telephones and Communication 0.6
56 56 Avery Arch Ring Binders Ann Chong 5894 87.68 58.1 1.49 Nunavut Binders and Binder Accessories 0.38
57 57 APC 7 Outlet Network SurgeArrest Surge Protector Ann Chong 5894 -68.22 80.48 4.5 Nunavut Appliances 0.55
58 58 Deflect-o RollaMat Studded, Beveled Mat for Medium Pile Carpeting Joy Bell 5925 -354.90 92.23 39.61 Nunavut Office Furnishings 0.67
59 59 Accessory4 Joy Bell 5925 -267.01 85.99 0.99 Nunavut Telephones and Communication 0.85
60 60 Personal Creations™ Ink Jet Cards and Labels Skye Norling 6016 3.63 11.48 5.43 Nunavut Paper 0.36
61 61 High Speed Automatic Electric Letter Opener Barry Weirich 6116 -1759.58 1637.53 24.49 Nunavut Scissors, Rulers and Trimmers 0.81
62 62 Xerox 1966 Grant Carroll 6182 -116.79 6.48 6.65 Nunavut Paper 0.36
63 63 Xerox 213 Grant Carroll 6182 -67.28 6.48 7.86 Nunavut Paper 0.37
64 64 Boston Electric Pencil Sharpener, Model 1818, Charcoal Black Adrian Hane 6535 -19.33 28.15 8.99 Nunavut Pens & Art Supplies 0.57
65 65 Hammermill CopyPlus Copy Paper (20Lb. and 84 Bright) Skye Norling 6884 -61.21 4.98 4.75 Nunavut Paper 0.36
66 66 Telephone Message Books with Fax/Mobile Section, 5 1/2" x 3 3/16" Skye Norling 6884 119.09 6.35 1.02 Nunavut Paper 0.39
67 67 Crate-A-Files™ Andrew Gjertsen 6916 -141.27 10.9 7.46 Nunavut Storage & Organization 0.59
68 68 Angle-D Binders with Locking Rings, Label Holders Ralph Knight 6980 -77.28 7.3 7.72 Nunavut Binders and Binder Accessories 0.38
69 69 80 Minute CD-R Spindle, 100/Pack - Staples Dorothy Wardle 6982 407.44 39.48 1.99 Nunavut Computer Peripherals 0.54
70 70 Bush Westfield Collection Bookcases, Dark Cherry Finish, Fully Assembled Dorothy Wardle 6982 -338.27 100.98 57.38 Nunavut Bookcases 0.78
71 71 12-1/2 Diameter Round Wall Clock Dorothy Wardle 6982 52.56 19.98 10.49 Nunavut Office Furnishings 0.49
72 72 SAFCO Arco Folding Chair Grant Carroll 7110 1902.24 276.2 24.49 Nunavut Chairs & Chairmats
73 73 #10 White Business Envelopes,4 1/8 x 9 1/2 Barry Weirich 7430 353.20 15.67 1.39 Nunavut Envelopes 0.38
74 74 3M Office Air Cleaner Beth Paige 7906 271.78 25.98 5.37 Nunavut Appliances 0.5
75 75 Global Leather and Oak Executive Chair, Black Sylvia Foulston 8391 -268.36 300.98 64.73 Nunavut Chairs & Chairmats 0.56
76 76 Xerox 1936 Nicole Hansen 8419 70.39 19.98 5.97 Nunavut Paper 0.38
77 77 Xerox 214 Nicole Hansen 8419 -86.62 6.48 7.03 Nunavut Paper 0.37
78 78 Carina Double Wide Media Storage Towers in Natural & Black Nicole Hansen 8833 -846.73 80.98 35 Nunavut Storage & Organization 0.81
79 79 Staples® General Use 3-Ring Binders Beth Paige 8995 8.05 1.88 1.49 Nunavut Binders and Binder Accessories 0.37
80 80 Xerox 1904 Beth Paige 8995 -78.02 6.48 5.86 Northwest Territories Paper 0.36
81 81 Luxo Professional Combination Clamp-On Lamps Beth Paige 8995 737.94 102.3 21.26 Northwest Territories Office Furnishings 0.59
82 82 Xerox 217 Beth Paige 8995 -191.28 6.48 8.19 Northwest Territories Paper 0.37
83 83 Revere Boxed Rubber Bands by Revere Beth Paige 8995 -21.49 1.89 0.76 Northwest Territories Rubber Bands 0.83
84 84 Acco Smartsocket™ Table Surge Protector, 6 Color-Coded Adapter Outlets Sylvia Foulston 9126 884.08 62.05 3.99 Northwest Territories Appliances 0.55
85 85 Tennsco Snap-Together Open Shelving Units, Starter Sets and Add-On Units Bryan Davis 9127 -329.49 279.48 35 Northwest Territories Storage & Organization 0.8
86 86 Hon 4070 Series Pagoda™ Round Back Stacking Chairs Joy Bell 9509 2825.15 320.98 58.95 Northwest Territories Chairs & Chairmats 0.57
87 87 Xerox 1887 Joy Bell 9509 2.13 18.97 5.21 Northwest Territories Paper 0.37
88 88 Xerox 1891 Joy Bell 9509 707.15 48.91 5.81 Northwest Territories Paper 0.38
89 89 Avery 506 Alan Barnes 9763 75.13 4.13 0.5 Northwest Territories Labels 0.39
90 90 Bush Heritage Pine Collection 5-Shelf Bookcase, Albany Pine Finish, *Special Order Grant Carroll 9927 -270.63 140.98 53.48 Northwest Territories Bookcases 0.65
91 91 Lifetime Advantage™ Folding Chairs, 4/Carton Grant Carroll 9927 3387.35 218.08 18.06 Northwest Territories Chairs & Chairmats 0.57
92 92 Microsoft Natural Multimedia Keyboard Grant Carroll 9927 -82.16 50.98 6.5 Northwest Territories Computer Peripherals 0.73
93 93 Staples Wirebound Steno Books, 6" x 9", 12/Pack Delfina Latchford 10022 -3.88 10.14 2.27 Northwest Territories Paper 0.36
94 94 GBC Pre-Punched Binding Paper, Plastic, White, 8-1/2" x 11" Don Jones 10437 -191.22 15.99 13.18 Northwest Territories Binders and Binder Accessories 0.37
95 95 Bevis Boat-Shaped Conference Table Doug Bickford 10499 31.21 262.11 62.74 Northwest Territories Tables 0.75
96 96 Linden® 12" Wall Clock With Oak Frame Doug Bickford 10535 -44.14 33.98 19.99 Northwest Territories Office Furnishings 0.55
97 97 Newell 326 Doug Bickford 10535 -0.79 1.76 0.7 Northwest Territories Pens & Art Supplies 0.56
98 98 Prismacolor Color Pencil Set Jamie Kunitz 10789 76.42 19.84 4.1 Northwest Territories Pens & Art Supplies 0.44
99 99 Xerox Blank Computer Paper Anthony Johnson 10791 93.36 19.98 5.77 Northwest Territories Paper 0.38
100 100 600 Series Flip Ralph Knight 10945 4.22 95.99 8.99 Northwest Territories Telephones and Communication 0.57

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,16 @@
Liste de dictionnaires
Clés de chaque valeur :
- code (str): Code INSEE
- nom (str): Nom de commune
- typeLiaison (int):
- zone (str): "metro" ou "" ou ""
- arrondissement (str): numéro d'arrondissement (3 chiffres)
- departement (str): numéro de département (2 chiffres)
- region (str): numéro de région (2 chiffres)
- type (str): ex. "commune-actuelle"
- rangChefLieu (int):
- siren (str): code SIREN ?
- codesPostaux (List[str]): liste de codes postaux
- population (int): population de la commune
- anciensCodes (List[str]): anciens codes INSEE
- chefLieu (str): code du chef-lieu

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,16 @@
import pandas as pd
from pandas import DataFrame
from source.pandas import get_dataframe
if __name__ == '__main__':
data: DataFrame = get_dataframe()
data["height_cm"] = data["height"].map(lambda h: h * 2.54)
print(data.groupby("sex").quantile([0.5], numeric_only=True))
means = data.groupby("sex").mean(["height", "earn"])
means["height_cm"] = means["height"].map(lambda h: h * 2.54)
stdevs = data.groupby("sex").std(numeric_only=True)
stdevs["height_cm"] = stdevs["height"].map(lambda h: h * 2.54)
print(data)
print(means)
print(stdevs)

View File

@ -0,0 +1,17 @@
from sqlalchemy import create_engine
import pandas as pd
pd.options.blipblop = 23
# A long string that contains the necessary Postgres login information
connection_string = "postgresql://{username}:{password}@{ipaddress}:{port}/{dbname}"
# Create the connection
connection = create_engine(connection_string)
# Load the data into a DataFrame
df = pd.read_sql_query("SELECT * FROM table_name", connection)
# Close the connection
connection.dispose()

View File

@ -0,0 +1,25 @@
import pandas as pd
from matplotlib import use, pyplot
# Utiliser tkinter
use("TkAgg")
pyplot.style.use('ggplot')
pyplot.rcParams["font.family"] = "Cabin"
# Données à afficher
data = pd.DataFrame(data={
"product": ["pomme", "poire", "banane", "pêche"],
"price": [1.99, 2.49, 2.99, 3.49]
})
def sector_label(pct: float) -> str:
value = pct * sum(data["price"]) / 100
return f"{value:.1f}\n{pct:.1f}%"
# Générer un graphique dans Matplotlib
axis = data.set_index("product").plot.pie(y="price", title="Prix", autopct=sector_label)
# Afficher le dernier graphique généré
axis.figure.savefig("eda-matplotlib-pie-themed.png")
pyplot.show()

View File

@ -0,0 +1,24 @@
import matplotlib
import pandas as pd
from matplotlib import pyplot
from matplotlib.axes import Axes
matplotlib.use("TkAgg")
pyplot.style.use('ggplot')
pyplot.rcParams["font.family"] = "Cabin"
data = pd.DataFrame(data={
"product": ["pomme", "poire", "banane", "pêche"],
"price": [1.99, 2.49, 2.99, 3.49],
"wpu": [200, 180, 140, 200]
})
# Générer un graphique dans Matplotlib
data.plot.bar(x="product", y=["price", "wpu"], rot=0.0, secondary_y="wpu", legend="reverse", title="Prix et poids unitaires")
prices, weights = pyplot.gcf().axes # type: Axes
prices.legend(bbox_to_anchor=(0.0, 1.1), loc="upper left")
weights.legend(bbox_to_anchor=(1.0, 1.1), loc="upper right")
# Il est difficile de personnaliser le contenu du graphique
options: dict = {"fontsize": 8, "color": "w", "rotation": 90, "label_type": "center"}
prices.bar_label(prices.containers[0], labels=[f"{p}" for p in data["price"]], **options)
weights.bar_label(weights.containers[0], labels=[f"{p}g" for p in data["wpu"]], **options)
pyplot.gcf().savefig("eda-matplotlib-bar-labeled.png")

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -0,0 +1,21 @@
from typing import Iterable
from matplotlib import pyplot as plot
from matplotlib.axes import Axes
from matplotlib.figure import Figure
import matplotlib
if __name__ == '__main__':
matplotlib.use("QtCairo")
labels: Iterable[str] = ("Janvier", "Février", "Mars", "Avril")
values: Iterable[float] = (50, 11.4, 91, 66.1)
figure: Figure
axis: Axes
figure, axis = plot.subplots(nrows=1, ncols=1)
axis.bar(x=labels, height=values, color="#00ff00")
circle = plot.Circle((2, 20), 2, color="#FF0000", fill=False)
axis.set_ylabel("Précipitations (mm)")
axis.set_xlabel("Mois")
axis.set_title("Précipitations pour 2022")
axis.add_artist(circle)
plot.show()

View File

@ -0,0 +1,19 @@
from typing import Iterable
from matplotlib import pyplot as plot
from matplotlib.axes import Axes
from matplotlib.figure import Figure
import matplotlib
if __name__ == '__main__':
matplotlib.use("QtCairo")
labels: Iterable[str] = ("Janvier", "Février", "Mars", "Avril")
values: Iterable[float] = (50, 11.4, 91, 66.1)
figure: Figure
axis: Axes
figure, axis = plot.subplots(nrows=1, ncols=1)
axis.bar(x=labels, height=values, color="#00ff00")
axis.set_ylabel("Précipitations (mm)")
axis.set_xlabel("Mois")
axis.set_title("Précipitations pour 2022")
figure.savefig("bar-chart.png", transparent=True)

View File

@ -0,0 +1,24 @@
"""
Display sales of various cities in a sunburst chart.
Given the cities can have recurring parents, we can have
a sunburst chart with 2 rings, the centermost ring for the
country, and the outmost ring to have sales per city.
"""
import matplotlib
import pandas as pd
from matplotlib import pyplot
if __name__ == '__main__':
matplotlib.use("QtCairo")
df = pd.DataFrame(data={
"country": ["France", "France", "Spain", "Spain"],
"city": ["Montpellier", "Bordeaux", "Madrid", "Valencia"],
"sales": [150_000, 127_000, 97_200, 137_250]
})
df.set_index(["country", "city"], inplace=True)
total: int = df["sales"].sum()
print(df)
axes = df.plot.pie(subplots=True, autopct=lambda x: f"{x * total / 100:.0f} {x:.2f}%")
pyplot.show()

View File

@ -0,0 +1,8 @@
import pandas as pd
from plotly.express import bar
if __name__ == '__main__':
df = pd.DataFrame(data={"label": ["Citron", "Pomme", "Mangue"], "price": [1.99, 3.97, 6.8]})
plot = bar(df, x="label", y="price")
plot.show()

View File

@ -0,0 +1,11 @@
import pandas as pd
from plotly import express as px
data = pd.read_csv("https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data", header=None,
names=["sepal-length", "sepal-width", "petal-length", "petal-width", "class"])
plot = px.scatter(data, x="sepal-length", y="sepal-width", size="petal-width", color="class", template="seaborn",
title="Iris flowers dataset",
labels={"sepal-length": "Sepal length", "sepal-width": "Sepal width", "petal-width": "Petal width", "class": "Class"})
plot.layout.update({"font": {"family": "Cabin", "size": 13}})
plot.show()

View File

@ -0,0 +1,21 @@
"""
Display sales of various cities in a sunburst chart.
Given the cities can have recurring parents, we can have
a sunburst chart with 2 rings, the centermost ring for the
country, and the outmost ring to have sales per city.
"""
import pandas as pd
import plotly
from plotly.express import sunburst
if __name__ == '__main__':
df = pd.DataFrame(data={
"country": ["France", "France", "Spain", "Spain", "England", "England", "England"],
"city": ["Montpellier", "Bordeaux", "Madrid", "Valencia", "London", "Manchester", "Bristol"],
"sales": [150_000, 127_000, 97_200, 137_250, 200_000, 180_000, 150_000]
})
plot = sunburst(df, path=["country", "city"], values="sales", title="Sales by country and city", template="ggplot2",
color_discrete_sequence=plotly.colors.qualitative.Dark2)
plot.layout.update({"font": {"family": "Cabin", "size": 13}})
plot.show()

Binary file not shown.

View File

@ -0,0 +1,24 @@
import dash
import pandas as pd
from dash import Dash, html, dash_table, dcc
from plotly.express import line
data = pd.read_excel("france-communes.xlsx")
dept = data.groupby("departement").sum("population")
app = Dash("demo")
app.layout = html.Div(children=[
html.H1(children="Dashboard"),
dash_table.DataTable(data=data.to_dict("records"), page_size=10),
dcc.Graph(id="dept-population", figure=line(dept, x=None, y="population")),
dcc.Dropdown(id="color-select", options=["#ff0000", "#00ff00"])
])
@app.callback(dash.Output("dept-population", "figure"), dash.Input("color-select", "value"))
def update_dept_population(color):
return line(dept, x=None, y="population", color_discrete_sequence=[color])
if __name__ == '__main__':
app.run(debug=True)

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="refresh_button">
<property name="text">
<string>Refresh</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>34</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,63 @@
import pandas as pd
from PySide6.QtCore import QObject, Slot
from PySide6.QtUiTools import QUiLoader
from PySide6.QtWidgets import QWidget, QMainWindow, QApplication, QPushButton
from matplotlib.axes import Axes
from matplotlib.backends.backend_qt import FigureCanvasQT
from matplotlib.backends.backend_qtcairo import FigureCanvasQTCairo
from matplotlib.figure import Figure
class Main(QObject):
"""Classe de gestion d'affichage de diagramme dans pyside."""
area: QWidget = None
window: QMainWindow | QWidget = None
canvas: FigureCanvasQT = None
refresh_button: QPushButton = None
plot1: Axes = None
data = pd.DataFrame({"age": [25, 45, 65], "prenom": ["Pierre", "Paul", "Jacques"]})
def __init__(self):
super().__init__()
self.window = QUiLoader().load("base-window.ui")
self.area = self.window.centralWidget()
self.refresh_button = self.window.refresh_button
# Créer un canevas compatible avec Matplotlib
self.canvas = FigureCanvasQTCairo()
self.canvas.figure = self.create_figures()
self.area.layout().addWidget(self.canvas)
self.show_bar()
# Répondre à un événement sur le bouton
self.refresh_button.clicked.connect(self.on_refresh_button_click)
@Slot()
def on_refresh_button_click(self):
"""Rafraîchir le graphique."""
self.show_line()
self.canvas.draw()
def create_figures(self) -> Figure:
"""Générer une image avec un graphique."""
figure = Figure(dpi=96)
self.plot1 = figure.add_subplot(111) # 1 colonne, 1 ligne, position 1
return figure
def show_bar(self):
"""Mettre à jour le canevas avec un diagramme en barres."""
self.canvas.figure.clear() # retirer tous les graphiques
self.plot1 = self.canvas.figure.add_subplot(111) # 1 colonne, 1 ligne, position 1
self.data.plot.bar(x="prenom", y="age", ax=self.plot1, rot=0)
def show_line(self):
"""Mettre à jour le canevas avec un diagramme en lignes."""
self.canvas.figure.clear() # retirer tous les graphiques
self.plot1 = self.canvas.figure.add_subplot(111) # 1 colonne, 1 ligne, position 1
self.data.plot.line(x="prenom", y="age", ax=self.plot1, color="#ffa820")
if __name__ == '__main__':
application = QApplication()
main = Main()
main.window.show()
application.exec()

View File

@ -0,0 +1,44 @@
from __future__ import annotations
import time
from PySide6.QtCore import QObject, Slot, QThreadPool
from PySide6.QtUiTools import QUiLoader
from PySide6.QtWidgets import QWidget, QMainWindow, QApplication, QPushButton
class Main(QObject):
"""Classe de gestion de threads dans Pyside."""
area: QWidget = None
window: QMainWindow | QWidget = None
refresh_button: QPushButton = None
thread_pool = QThreadPool()
counter: int = 0
def __init__(self):
super().__init__()
self.window = QUiLoader().load("base-window.ui")
self.area = self.window.centralWidget()
self.refresh_button = self.window.refresh_button
# Répondre à un événement sur le bouton
self.refresh_button.clicked.connect(self.on_refresh_button_click)
@Slot()
def on_refresh_button_click(self):
"""Rafraîchir le graphique."""
self.refresh_button.setDisabled(True)
self.thread_pool.start(self.counter_updater)
def counter_updater(self):
"""Thread."""
while True:
self.counter += 1
self.refresh_button.setText(f"{self.counter}")
time.sleep(1.0)
if __name__ == '__main__':
application = QApplication()
main = Main()
main.window.show()
application.exec()

View File

@ -0,0 +1,12 @@
import pandas as pd
from plotly import express
values = pd.Series(
data=[1.99, 2.49, 2.99, 3.49],
index=["pomme", "poire", "banane", "peche"],
name="price"
)
# Générer un graphique
figure = express.bar(values, x=None, y="price")
figure.show()

View File

@ -0,0 +1,10 @@
import pandas as pd
from plotly import express as px
data = pd.DataFrame(data={
"product": ["pomme", "poire", "banane", "pêche"],
"price": [1.99, 2.49, 2.99, 3.49], "wpu": [200, 180, 140, 200]
})
figure = px.bar(data, y="price", x="product", title="Prix", color="price", color_continuous_scale=["red", "orange", "yellow", "#8F0"])
figure.layout.update({"template": "seaborn", "title": "Prix au kilo", "font": {"family": "Cabin", "size": 13}})
figure.show()

View File

@ -0,0 +1,18 @@
import pandas as pd
from plotly.graph_objs import Figure, Bar
data = pd.DataFrame(data={
"product": ["pomme", "poire", "banane", "pêche"],
"price": [1.99, 2.49, 2.99, 3.49], "wpu": [200, 180, 140, 200]
})
figure = Figure([
Bar(name="Prix", x=data["product"], y=data["price"], yaxis="y", offsetgroup=1),
Bar(name="Poids", x=data["product"], y=data["wpu"], yaxis="y2", offsetgroup=2),
])
# Afficher le dernier graphique généré
figure.layout.update({
"template": "seaborn",
"title": "Prix et poids unitaires", "font": {"family": "Cabin", "size": 13},
"yaxis": {"title": "Prix (€)"}, "yaxis2": {"title": "Poids (g)", "overlaying": "y", "side": "right"}
})
figure.show()

View File

@ -0,0 +1,10 @@
import pandas as pd
from plotly import express as px
data = pd.DataFrame(data={
"product": ["pomme", "poire", "banane", "pêche"],
"price": [1.99, 2.49, 2.99, 3.49], "wpu": [200, 180, 140, 200]
})
figure = px.pie(data, values="price", names="product", title="Prix", color_discrete_sequence=["red", "orange", "yellow", "#8F0"])
figure.layout.update({"template": "seaborn", "title": "Prix au kilo", "font": {"family": "Cabin", "size": 13}})
figure.show()

View File

@ -0,0 +1,15 @@
import pandas as pd
from plotly import express as px
data = pd.DataFrame(data={
"product": ["pomme", "poire", "banane", "pêche"],
"price": [1.99, 2.49, 2.99, 3.49], "wpu": [200, 180, 140, 200]
})
figure = px.pie(data, values="price", names="product", title="Prix")
# Afficher le dernier graphique généré
figure.layout.update({
"template": "seaborn",
"title": "Prix au kilo", "font": {"family": "Cabin", "size": 13},
})
figure.update_traces(**{"textinfo": "label+value", "texttemplate": "%{label}<br>%{value:.2f}"})
figure.show()

View File

@ -0,0 +1,13 @@
import pandas as pd
from plotly import express
data = pd.DataFrame(data={
"product": ["pomme", "poire", "banane", "pêche"],
"price": [1.99, 2.49, 2.99, 3.49],
"wpu": [200, 180, 140, 200]
})
# Générer un graphique. Plotly express ne prend en charge qu'un seul graphique par figure
figure = express.bar(data, x="product", y="price", title="Prix", template="seaborn",
labels={"price": "Prix", "product": "Produit"})
figure.layout.update({"font": {"family": "Cabin", "size": 13}})
figure.show()

163
source/requirements.txt Normal file
View File

@ -0,0 +1,163 @@
amqp==5.2.0
anyio==4.3.0
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
arrow==1.3.0
asttokens==2.4.1
async-lru==2.0.4
attrs==23.2.0
Babel==2.14.0
beautifulsoup4==4.12.3
billiard==4.2.0
bleach==6.1.0
blinker==1.8.1
cairocffi==1.7.0
celery==5.4.0
certifi==2024.2.2
cffi==1.16.0
charset-normalizer==3.3.2
click==8.1.7
click-didyoumean==0.3.1
click-plugins==1.1.1
click-repl==0.3.0
cloudpickle==3.0.0
comm==0.2.2
contexttimer==0.3.3
contourpy==1.2.1
cycler==0.12.1
dash==2.16.1
dash-core-components==2.0.0
dash-html-components==2.0.0
dash-table==5.0.0
dask==2024.6.2
dask-expr==1.1.6
debugpy==1.8.1
decorator==5.1.1
defusedxml==0.7.1
distributed==2024.6.2
duckdb==1.0.0
et-xmlfile==1.1.0
executing==2.0.1
fastjsonschema==2.19.1
Flask==3.0.3
fonttools==4.51.0
fqdn==1.5.1
fsspec==2024.6.1
greenlet==3.0.3
h11==0.14.0
httpcore==1.0.5
httpx==0.27.0
idna==3.7
importlib_metadata==7.1.0
ipykernel==6.29.4
ipython==8.24.0
ipywidgets==8.1.2
isoduration==20.11.0
itsdangerous==2.2.0
jedi==0.19.1
Jinja2==3.1.3
json5==0.9.25
jsonpointer==2.4
jsonschema==4.22.0
jsonschema-specifications==2023.12.1
jupyter==1.0.0
jupyter-console==6.6.3
jupyter-events==0.10.0
jupyter-lsp==2.2.5
jupyter_client==8.6.1
jupyter_core==5.7.2
jupyter_server==2.14.0
jupyter_server_terminals==0.5.3
jupyterlab==4.1.8
jupyterlab_pygments==0.3.0
jupyterlab_server==2.27.1
jupyterlab_widgets==3.0.10
kiwisolver==1.4.5
kombu==5.3.7
locket==1.0.0
MarkupSafe==2.1.5
matplotlib==3.8.4
matplotlib-inline==0.1.7
mistune==3.0.2
msgpack==1.0.8
nbclient==0.10.0
nbconvert==7.16.4
nbformat==5.10.4
nest-asyncio==1.6.0
notebook==7.1.3
notebook_shim==0.2.4
numpy==1.26.4
openpyxl==3.1.2
overrides==7.7.0
packaging==24.0
pandas==2.2.2
pandas-stubs==2.2.2.240603
pandocfilters==1.5.1
parso==0.8.4
partd==1.4.2
pexpect==4.9.0
pillow==10.3.0
platformdirs==4.2.1
plotly==5.21.0
polars==0.20.31
prometheus_client==0.20.0
prompt-toolkit==3.0.43
psutil==5.9.8
psycopg==3.2.1
ptyprocess==0.7.0
pure-eval==0.2.2
pyarrow==16.1.0
pycparser==2.22
Pygments==2.17.2
pylibmc==1.6.3
pyparsing==3.1.2
PySide6==6.7.0
PySide6_Addons==6.7.0
PySide6_Essentials==6.7.0
python-dateutil==2.9.0.post0
python-json-logger==2.0.7
pytz==2024.1
PyYAML==6.0.1
pyzmq==26.0.2
qtconsole==5.5.1
QtPy==2.4.1
redis==5.0.4
referencing==0.35.0
requests==2.31.0
retrying==1.3.4
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rpds-py==0.18.0
Send2Trash==1.8.3
setuptools==69.5.1
shiboken6==6.7.0
six==1.16.0
sniffio==1.3.1
sortedcontainers==2.4.0
soupsieve==2.5
SQLAlchemy==2.0.31
stack-data==0.6.3
tblib==3.0.0
tenacity==8.2.3
terminado==0.18.1
tinycss2==1.3.0
toolz==0.12.1
tornado==6.4
traitlets==5.14.3
types-python-dateutil==2.9.0.20240316
types-pytz==2024.1.0.20240417
typing_extensions==4.11.0
tzdata==2024.1
Unidecode==1.3.8
uri-template==1.3.0
urllib3==2.2.1
vine==5.1.0
wcwidth==0.2.13
webcolors==1.13
webencodings==0.5.1
websocket-client==1.8.0
Werkzeug==3.0.2
widgetsnbextension==4.0.10
XlsxWriter==3.2.0
zict==3.0.0
zipp==3.18.1

View File

@ -0,0 +1,10 @@
from sklearn.linear_model import LinearRegression
model = LinearRegression()
x = [[0, 1], [1, 1], [2, 1]]
y = [0, 1, 2]
target = [1, 1, 1]
coeff: LinearRegression = model.fit(x, y)
# L'ordonne des points est 0.5 + 0.5 * x
print(coeff.coef_)

View File

@ -0,0 +1,9 @@
from celery import Celery
application = Celery("demo", backend="redis://localhost:6379/0", broker='redis://localhost//')
@application.task
def show_text():
print("Hello")
return "Hello"

View File

@ -0,0 +1,4 @@
from celeryapp import show_text
show_text.delay()