├── requirements.txt ├── db.sqlite3 ├── demo ├── bar.png └── pie.png ├── .gitignore ├── README.md └── app └── main.ipynb /requirements.txt: -------------------------------------------------------------------------------- 1 | pandas==1.4.3 2 | numpy==1.23.1 3 | jupyter==1.0.0 -------------------------------------------------------------------------------- /db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kapitoshk4/py-restaurant-data-analysis/HEAD/db.sqlite3 -------------------------------------------------------------------------------- /demo/bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kapitoshk4/py-restaurant-data-analysis/HEAD/demo/bar.png -------------------------------------------------------------------------------- /demo/pie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kapitoshk4/py-restaurant-data-analysis/HEAD/demo/pie.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vscode/ 3 | *.iml 4 | .env 5 | .DS_Store 6 | venv/ 7 | .pytest_cache/ 8 | **__pycache__/ 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Restaurant data analysis 2 | 3 | - Read [the guideline](https://github.com/mate-academy/py-task-guideline/blob/main/README.md) before start 4 | 5 | 6 | ### Task 7 | 8 | You're given part of restaurant's [db](db.sqlite3) with product, order & order_items info. 9 | Your task is to extract data from db using SQL queries & perform data analysis on it. 10 | Detailed step-by-step task you will find [here](app/main.ipynb). 11 | 12 | Over-all notes: 13 | - Do not use any ORM for data extraction - perform only raw SQL queries using `sqlite3` module. 14 | - You can use `group by` on SQL level or on pandas level - it's your choice. 15 | - If you think, that some additional analytics should be applied - just make it. 16 | -------------------------------------------------------------------------------- /app/main.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": { 7 | "collapsed": true, 8 | "pycharm": { 9 | "name": "#%%\n" 10 | } 11 | }, 12 | "outputs": [], 13 | "source": [ 14 | "import pandas as pd\n", 15 | "import numpy as np" 16 | ] 17 | }, 18 | { 19 | "cell_type": "markdown", 20 | "source": [ 21 | "# Task 0\n", 22 | "Data extraction: get the data from 3 tables & combine it into single `.csv` file.\n", 23 | "After that read this file using pandas to create Dataframe.\n", 24 | "So it will be all joined data in 1 dataframe. Quick check - should be 74818 rows in it." 25 | ], 26 | "metadata": { 27 | "collapsed": false, 28 | "pycharm": { 29 | "name": "#%% md\n" 30 | } 31 | } 32 | }, 33 | { 34 | "cell_type": "code", 35 | "execution_count": null, 36 | "outputs": [], 37 | "source": [ 38 | "# write your code here" 39 | ], 40 | "metadata": { 41 | "collapsed": false, 42 | "pycharm": { 43 | "name": "#%%\n" 44 | } 45 | } 46 | }, 47 | { 48 | "cell_type": "markdown", 49 | "source": [ 50 | "# Task 1\n", 51 | "Get Top 10 most popular products in restaurant sold by Quantity.\n", 52 | "Count how many times each product was sold and create a pie chart with percentage of popularity (by quantity) for top 10 of them.\n", 53 | "\n", 54 | "Example:\n", 55 | "\n", 56 | "![pie chart](../demo/pie.png)" 57 | ], 58 | "metadata": { 59 | "collapsed": false, 60 | "pycharm": { 61 | "name": "#%% md\n" 62 | } 63 | } 64 | }, 65 | { 66 | "cell_type": "code", 67 | "execution_count": null, 68 | "outputs": [], 69 | "source": [ 70 | "# write your code here" 71 | ], 72 | "metadata": { 73 | "collapsed": false, 74 | "pycharm": { 75 | "name": "#%%\n" 76 | } 77 | } 78 | }, 79 | { 80 | "cell_type": "markdown", 81 | "source": [ 82 | "# Task 2\n", 83 | "Calculate `Item Price` (Product Price * Quantity) for each Order Item in dataframe.\n", 84 | "And Make the same Top 10 pie chart, but this time by `Item Price`. So this chart should describe not the most popular products by quantity, but which products (top 10) make the most money for restaurant. It should be also with percentage." 85 | ], 86 | "metadata": { 87 | "collapsed": false, 88 | "pycharm": { 89 | "name": "#%% md\n" 90 | } 91 | } 92 | }, 93 | { 94 | "cell_type": "code", 95 | "execution_count": null, 96 | "outputs": [], 97 | "source": [ 98 | "# write your code here" 99 | ], 100 | "metadata": { 101 | "collapsed": false, 102 | "pycharm": { 103 | "name": "#%%\n", 104 | "is_executing": true 105 | } 106 | } 107 | }, 108 | { 109 | "cell_type": "markdown", 110 | "source": [ 111 | "# Task 3\n", 112 | "Calculate `Order Hour` based on `Order Datetime`, which will tell about the specific our the order was created (from 0 to 23). Using `Order Hour` create a bar chart, which will tell the total restaurant income based on the hour order was created. So on x-axis - it will be values from 0 to 23 (hours), on y-axis - it will be the total sum of order prices, which were sold on that hour.\n", 113 | "\n", 114 | "Example:\n", 115 | "\n", 116 | "![bar chart](../demo/bar.png)" 117 | ], 118 | "metadata": { 119 | "collapsed": false, 120 | "pycharm": { 121 | "name": "#%% md\n" 122 | } 123 | } 124 | }, 125 | { 126 | "cell_type": "code", 127 | "execution_count": null, 128 | "outputs": [], 129 | "source": [ 130 | "# write your code here" 131 | ], 132 | "metadata": { 133 | "collapsed": false, 134 | "pycharm": { 135 | "name": "#%%\n" 136 | } 137 | } 138 | }, 139 | { 140 | "cell_type": "markdown", 141 | "source": [ 142 | "# Task 4\n", 143 | "Make similar bar chart, but right now with `Order Day Of The Week` (from Monday to Sunday), and also analyze total restaurant income by each day of the week." 144 | ], 145 | "metadata": { 146 | "collapsed": false, 147 | "pycharm": { 148 | "name": "#%% md\n" 149 | } 150 | } 151 | }, 152 | { 153 | "cell_type": "code", 154 | "execution_count": null, 155 | "outputs": [], 156 | "source": [ 157 | "# write your code here" 158 | ], 159 | "metadata": { 160 | "collapsed": false, 161 | "pycharm": { 162 | "name": "#%%\n" 163 | } 164 | } 165 | } 166 | ], 167 | "metadata": { 168 | "kernelspec": { 169 | "display_name": "Python 3", 170 | "language": "python", 171 | "name": "python3" 172 | }, 173 | "language_info": { 174 | "codemirror_mode": { 175 | "name": "ipython", 176 | "version": 2 177 | }, 178 | "file_extension": ".py", 179 | "mimetype": "text/x-python", 180 | "name": "python", 181 | "nbconvert_exporter": "python", 182 | "pygments_lexer": "ipython2", 183 | "version": "2.7.6" 184 | } 185 | }, 186 | "nbformat": 4, 187 | "nbformat_minor": 0 188 | } --------------------------------------------------------------------------------