Skip to content

Instantly share code, notes, and snippets.

@haydarai
Created December 10, 2018 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haydarai/f41701409817538d53bccbad81667d1e to your computer and use it in GitHub Desktop.
Save haydarai/f41701409817538d53bccbad81667d1e to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 69,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <div class=\"bk-root\">\n",
" <a href=\"https://bokeh.pydata.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n",
" <span id=\"4003\">Loading BokehJS ...</span>\n",
" </div>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"\n",
"(function(root) {\n",
" function now() {\n",
" return new Date();\n",
" }\n",
"\n",
" var force = true;\n",
"\n",
" if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n",
" root._bokeh_onload_callbacks = [];\n",
" root._bokeh_is_loading = undefined;\n",
" }\n",
"\n",
" var JS_MIME_TYPE = 'application/javascript';\n",
" var HTML_MIME_TYPE = 'text/html';\n",
" var EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n",
" var CLASS_NAME = 'output_bokeh rendered_html';\n",
"\n",
" /**\n",
" * Render data to the DOM node\n",
" */\n",
" function render(props, node) {\n",
" var script = document.createElement(\"script\");\n",
" node.appendChild(script);\n",
" }\n",
"\n",
" /**\n",
" * Handle when an output is cleared or removed\n",
" */\n",
" function handleClearOutput(event, handle) {\n",
" var cell = handle.cell;\n",
"\n",
" var id = cell.output_area._bokeh_element_id;\n",
" var server_id = cell.output_area._bokeh_server_id;\n",
" // Clean up Bokeh references\n",
" if (id != null && id in Bokeh.index) {\n",
" Bokeh.index[id].model.document.clear();\n",
" delete Bokeh.index[id];\n",
" }\n",
"\n",
" if (server_id !== undefined) {\n",
" // Clean up Bokeh references\n",
" var cmd = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n",
" cell.notebook.kernel.execute(cmd, {\n",
" iopub: {\n",
" output: function(msg) {\n",
" var id = msg.content.text.trim();\n",
" if (id in Bokeh.index) {\n",
" Bokeh.index[id].model.document.clear();\n",
" delete Bokeh.index[id];\n",
" }\n",
" }\n",
" }\n",
" });\n",
" // Destroy server and session\n",
" var cmd = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n",
" cell.notebook.kernel.execute(cmd);\n",
" }\n",
" }\n",
"\n",
" /**\n",
" * Handle when a new output is added\n",
" */\n",
" function handleAddOutput(event, handle) {\n",
" var output_area = handle.output_area;\n",
" var output = handle.output;\n",
"\n",
" // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n",
" if ((output.output_type != \"display_data\") || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n",
" return\n",
" }\n",
"\n",
" var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n",
"\n",
" if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n",
" toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n",
" // store reference to embed id on output_area\n",
" output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n",
" }\n",
" if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n",
" var bk_div = document.createElement(\"div\");\n",
" bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n",
" var script_attrs = bk_div.children[0].attributes;\n",
" for (var i = 0; i < script_attrs.length; i++) {\n",
" toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n",
" }\n",
" // store reference to server id on output_area\n",
" output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n",
" }\n",
" }\n",
"\n",
" function register_renderer(events, OutputArea) {\n",
"\n",
" function append_mime(data, metadata, element) {\n",
" // create a DOM node to render to\n",
" var toinsert = this.create_output_subarea(\n",
" metadata,\n",
" CLASS_NAME,\n",
" EXEC_MIME_TYPE\n",
" );\n",
" this.keyboard_manager.register_events(toinsert);\n",
" // Render to node\n",
" var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n",
" render(props, toinsert[toinsert.length - 1]);\n",
" element.append(toinsert);\n",
" return toinsert\n",
" }\n",
"\n",
" /* Handle when an output is cleared or removed */\n",
" events.on('clear_output.CodeCell', handleClearOutput);\n",
" events.on('delete.Cell', handleClearOutput);\n",
"\n",
" /* Handle when a new output is added */\n",
" events.on('output_added.OutputArea', handleAddOutput);\n",
"\n",
" /**\n",
" * Register the mime type and append_mime function with output_area\n",
" */\n",
" OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n",
" /* Is output safe? */\n",
" safe: true,\n",
" /* Index of renderer in `output_area.display_order` */\n",
" index: 0\n",
" });\n",
" }\n",
"\n",
" // register the mime type if in Jupyter Notebook environment and previously unregistered\n",
" if (root.Jupyter !== undefined) {\n",
" var events = require('base/js/events');\n",
" var OutputArea = require('notebook/js/outputarea').OutputArea;\n",
"\n",
" if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n",
" register_renderer(events, OutputArea);\n",
" }\n",
" }\n",
"\n",
" \n",
" if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
" root._bokeh_timeout = Date.now() + 5000;\n",
" root._bokeh_failed_load = false;\n",
" }\n",
"\n",
" var NB_LOAD_WARNING = {'data': {'text/html':\n",
" \"<div style='background-color: #fdd'>\\n\"+\n",
" \"<p>\\n\"+\n",
" \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
" \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
" \"</p>\\n\"+\n",
" \"<ul>\\n\"+\n",
" \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
" \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
" \"</ul>\\n\"+\n",
" \"<code>\\n\"+\n",
" \"from bokeh.resources import INLINE\\n\"+\n",
" \"output_notebook(resources=INLINE)\\n\"+\n",
" \"</code>\\n\"+\n",
" \"</div>\"}};\n",
"\n",
" function display_loaded() {\n",
" var el = document.getElementById(\"4003\");\n",
" if (el != null) {\n",
" el.textContent = \"BokehJS is loading...\";\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" if (el != null) {\n",
" el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n",
" }\n",
" } else if (Date.now() < root._bokeh_timeout) {\n",
" setTimeout(display_loaded, 100)\n",
" }\n",
" }\n",
"\n",
"\n",
" function run_callbacks() {\n",
" try {\n",
" root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n",
" }\n",
" finally {\n",
" delete root._bokeh_onload_callbacks\n",
" }\n",
" console.info(\"Bokeh: all callbacks have finished\");\n",
" }\n",
"\n",
" function load_libs(js_urls, callback) {\n",
" root._bokeh_onload_callbacks.push(callback);\n",
" if (root._bokeh_is_loading > 0) {\n",
" console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
" return null;\n",
" }\n",
" if (js_urls == null || js_urls.length === 0) {\n",
" run_callbacks();\n",
" return null;\n",
" }\n",
" console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
" root._bokeh_is_loading = js_urls.length;\n",
" for (var i = 0; i < js_urls.length; i++) {\n",
" var url = js_urls[i];\n",
" var s = document.createElement('script');\n",
" s.src = url;\n",
" s.async = false;\n",
" s.onreadystatechange = s.onload = function() {\n",
" root._bokeh_is_loading--;\n",
" if (root._bokeh_is_loading === 0) {\n",
" console.log(\"Bokeh: all BokehJS libraries loaded\");\n",
" run_callbacks()\n",
" }\n",
" };\n",
" s.onerror = function() {\n",
" console.warn(\"failed to load library \" + url);\n",
" };\n",
" console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
" document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
" }\n",
" };var element = document.getElementById(\"4003\");\n",
" if (element == null) {\n",
" console.log(\"Bokeh: ERROR: autoload.js configured with elementid '4003' but no matching script tag was found. \")\n",
" return false;\n",
" }\n",
"\n",
" var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.2.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.2.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.2.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-1.0.2.min.js\"];\n",
"\n",
" var inline_js = [\n",
" function(Bokeh) {\n",
" Bokeh.set_log_level(\"info\");\n",
" },\n",
" \n",
" function(Bokeh) {\n",
" \n",
" },\n",
" function(Bokeh) {\n",
" console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-1.0.2.min.css\");\n",
" Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.2.min.css\");\n",
" console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.2.min.css\");\n",
" Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.2.min.css\");\n",
" console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.2.min.css\");\n",
" Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.2.min.css\");\n",
" }\n",
" ];\n",
"\n",
" function run_inline_js() {\n",
" \n",
" if ((root.Bokeh !== undefined) || (force === true)) {\n",
" for (var i = 0; i < inline_js.length; i++) {\n",
" inline_js[i].call(root, root.Bokeh);\n",
" }if (force === true) {\n",
" display_loaded();\n",
" }} else if (Date.now() < root._bokeh_timeout) {\n",
" setTimeout(run_inline_js, 100);\n",
" } else if (!root._bokeh_failed_load) {\n",
" console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
" root._bokeh_failed_load = true;\n",
" } else if (force !== true) {\n",
" var cell = $(document.getElementById(\"4003\")).parents('.cell').data().cell;\n",
" cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
" }\n",
"\n",
" }\n",
"\n",
" if (root._bokeh_is_loading === 0) {\n",
" console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
" run_inline_js();\n",
" } else {\n",
" load_libs(js_urls, function() {\n",
" console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n",
" run_inline_js();\n",
" });\n",
" }\n",
"}(window));"
],
"application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n\n if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n \n\n \n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n var NB_LOAD_WARNING = {'data': {'text/html':\n \"<div style='background-color: #fdd'>\\n\"+\n \"<p>\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"</p>\\n\"+\n \"<ul>\\n\"+\n \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n \"<li>use INLINE resources instead, as so:</li>\\n\"+\n \"</ul>\\n\"+\n \"<code>\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"</code>\\n\"+\n \"</div>\"}};\n\n function display_loaded() {\n var el = document.getElementById(\"4003\");\n if (el != null) {\n el.textContent = \"BokehJS is loading...\";\n }\n if (root.Bokeh !== undefined) {\n if (el != null) {\n el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(display_loaded, 100)\n }\n }\n\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n }\n finally {\n delete root._bokeh_onload_callbacks\n }\n console.info(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(js_urls, callback) {\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = js_urls.length;\n for (var i = 0; i < js_urls.length; i++) {\n var url = js_urls[i];\n var s = document.createElement('script');\n s.src = url;\n s.async = false;\n s.onreadystatechange = s.onload = function() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.log(\"Bokeh: all BokehJS libraries loaded\");\n run_callbacks()\n }\n };\n s.onerror = function() {\n console.warn(\"failed to load library \" + url);\n };\n console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.getElementsByTagName(\"head\")[0].appendChild(s);\n }\n };var element = document.getElementById(\"4003\");\n if (element == null) {\n console.log(\"Bokeh: ERROR: autoload.js configured with elementid '4003' but no matching script tag was found. \")\n return false;\n }\n\n var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.2.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.2.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.2.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-1.0.2.min.js\"];\n\n var inline_js = [\n function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n \n function(Bokeh) {\n \n },\n function(Bokeh) {\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-1.0.2.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.2.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.2.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.2.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.2.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.2.min.css\");\n }\n ];\n\n function run_inline_js() {\n \n if ((root.Bokeh !== undefined) || (force === true)) {\n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }if (force === true) {\n display_loaded();\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n var cell = $(document.getElementById(\"4003\")).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n\n }\n\n if (root._bokeh_is_loading === 0) {\n console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(js_urls, function() {\n console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));"
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import pandas as pd\n",
"from bokeh.plotting import figure, output_file, show\n",
"from bokeh.io import output_notebook\n",
"\n",
"output_notebook()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Summary"
]
},
{
"cell_type": "code",
"execution_count": 70,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>AMOUNT</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>4.384728e+07</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" AMOUNT\n",
"0 4.384728e+07"
]
},
"execution_count": 70,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_average_month = pd.read_json('http://35.240.46.26:5000/sales/summary/month/avg')\n",
"df_average_month"
]
},
{
"cell_type": "code",
"execution_count": 71,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>AMOUNT</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>4.384728e+07</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" AMOUNT\n",
"0 4.384728e+07"
]
},
"execution_count": 71,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_sum_month = pd.read_json('http://35.240.46.26:5000/sales/summary/month/sum')\n",
"df_sum_month"
]
},
{
"cell_type": "code",
"execution_count": 72,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>AMOUNT</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>4.879302e+06</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" AMOUNT\n",
"0 4.879302e+06"
]
},
"execution_count": 72,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_average_year = pd.read_json('http://35.240.46.26:5000/sales/summary/year/avg')\n",
"df_average_year"
]
},
{
"cell_type": "code",
"execution_count": 73,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>AMOUNT</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>4.384728e+07</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" AMOUNT\n",
"0 4.384728e+07"
]
},
"execution_count": 73,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_average_month = pd.read_json('http://35.240.46.26:5000/sales/summary/month/avg')\n",
"df_average_month"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Sales Overall"
]
},
{
"cell_type": "code",
"execution_count": 74,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" <div class=\"bk-root\" id=\"64db2b56-98e6-4cb7-9426-6fb68ccc8cb7\"></div>\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"(function(root) {\n",
" function embed_document(root) {\n",
" \n",
" var docs_json = {\"fd6ec199-068a-49de-b72a-153caed6a5ad\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"4015\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"4020\",\"type\":\"LinearAxis\"}],\"renderers\":[{\"id\":\"4015\",\"type\":\"LinearAxis\"},{\"id\":\"4019\",\"type\":\"Grid\"},{\"id\":\"4020\",\"type\":\"LinearAxis\"},{\"id\":\"4024\",\"type\":\"Grid\"},{\"id\":\"4033\",\"type\":\"BoxAnnotation\"},{\"id\":\"4043\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"4004\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"4031\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"4007\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"4011\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"4009\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"4013\",\"type\":\"LinearScale\"}},\"id\":\"4005\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"4033\",\"type\":\"BoxAnnotation\"},{\"attributes\":{},\"id\":\"4013\",\"type\":\"LinearScale\"},{\"attributes\":{\"data_source\":{\"id\":\"4040\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"4041\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"4042\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"4044\",\"type\":\"CDSView\"}},\"id\":\"4043\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"axis_label\":\"Year\",\"formatter\":{\"id\":\"4153\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"4005\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"4016\",\"type\":\"BasicTicker\"}},\"id\":\"4015\",\"type\":\"LinearAxis\"},{\"attributes\":{\"source\":{\"id\":\"4040\",\"type\":\"ColumnDataSource\"}},\"id\":\"4044\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"4151\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"plot\":{\"id\":\"4005\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"4016\",\"type\":\"BasicTicker\"}},\"id\":\"4019\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"4016\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"4153\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"4154\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"4155\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"4005\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"4021\",\"type\":\"BasicTicker\"}},\"id\":\"4024\",\"type\":\"Grid\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"4025\",\"type\":\"PanTool\"},{\"id\":\"4026\",\"type\":\"WheelZoomTool\"},{\"id\":\"4027\",\"type\":\"BoxZoomTool\"},{\"id\":\"4028\",\"type\":\"SaveTool\"},{\"id\":\"4029\",\"type\":\"ResetTool\"},{\"id\":\"4030\",\"type\":\"HelpTool\"}]},\"id\":\"4031\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"4021\",\"type\":\"BasicTicker\"},{\"attributes\":{\"line_color\":\"#1f77b4\",\"line_width\":2,\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"4041\",\"type\":\"Line\"},{\"attributes\":{\"callback\":null,\"data\":{\"x\":[1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017],\"y\":{\"__ndarray__\":\"AAAgPWpA1EAAgDEqbJf9QACAiuJaOv5AAAAApGDr4EAAAHehEHjVQAAA/MBdD+RAAAASKsT440AAAAKZucvSQACQhkcpOfBAAKDXzEgfAUEAQE+td6ruQAAAdEihoOJAALzgCRuEBUEAAFWkHA3xQAAAJUid3vtAAAAA2LN00EAAABU0I+TwQAAAKD7KgeBAAACXuM490EAAAOwy8yTSQIBCpNZraf9AAACE13M92UAAADAmTLzVQAAAJj1a8tFAAABxMyP22EAAwCOjABDyQAAARHtUkPRA\",\"dtype\":\"float64\",\"shape\":[27]}},\"selected\":{\"id\":\"4154\",\"type\":\"Selection\"},\"selection_policy\":{\"id\":\"4155\",\"type\":\"UnionRenderers\"}},\"id\":\"4040\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"4025\",\"type\":\"PanTool\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#1f77b4\",\"line_width\":2,\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"4042\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"4026\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"overlay\":{\"id\":\"4033\",\"type\":\"BoxAnnotation\"}},\"id\":\"4027\",\"type\":\"BoxZoomTool\"},{\"attributes\":{},\"id\":\"4028\",\"type\":\"SaveTool\"},{\"attributes\":{\"callback\":null},\"id\":\"4009\",\"type\":\"DataRange1d\"},{\"attributes\":{\"plot\":null,\"text\":\"Sales overall (Every year)\"},\"id\":\"4004\",\"type\":\"Title\"},{\"attributes\":{},\"id\":\"4029\",\"type\":\"ResetTool\"},{\"attributes\":{\"axis_label\":\"Amount\",\"formatter\":{\"id\":\"4151\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"4005\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"4021\",\"type\":\"BasicTicker\"}},\"id\":\"4020\",\"type\":\"LinearAxis\"},{\"attributes\":{\"callback\":null},\"id\":\"4007\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"4030\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"4011\",\"type\":\"LinearScale\"}],\"root_ids\":[\"4005\"]},\"title\":\"Bokeh Application\",\"version\":\"1.0.2\"}};\n",
" var render_items = [{\"docid\":\"fd6ec199-068a-49de-b72a-153caed6a5ad\",\"roots\":{\"4005\":\"64db2b56-98e6-4cb7-9426-6fb68ccc8cb7\"}}];\n",
" root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
"\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" embed_document(root);\n",
" } else {\n",
" var attempts = 0;\n",
" var timer = setInterval(function(root) {\n",
" if (root.Bokeh !== undefined) {\n",
" embed_document(root);\n",
" clearInterval(timer);\n",
" }\n",
" attempts++;\n",
" if (attempts > 100) {\n",
" console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
" clearInterval(timer);\n",
" }\n",
" }, 10, root)\n",
" }\n",
"})(window);"
],
"application/vnd.bokehjs_exec.v0+json": ""
},
"metadata": {
"application/vnd.bokehjs_exec.v0+json": {
"id": "4005"
}
},
"output_type": "display_data"
}
],
"source": [
"df_overall = pd.read_json('http://35.240.46.26:5000/sales/last/overall')\n",
"df_overall = df_overall[:-1] # remove 2018\n",
"\n",
"p_last_overall = figure(title=\"Sales overall (Every year)\", x_axis_label='Year', y_axis_label='Amount')\n",
"p_last_overall.line(df_overall.YEAR, df_overall.AMOUNT, line_width=2)\n",
"show(p_last_overall)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Sales overall (This year)"
]
},
{
"cell_type": "code",
"execution_count": 75,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" <div class=\"bk-root\" id=\"504c11ce-54ad-405c-98d1-4435c8f4bcca\"></div>\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"(function(root) {\n",
" function embed_document(root) {\n",
" \n",
" var docs_json = {\"3ed254b8-0528-4241-95dc-8013eb684571\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"4216\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"4221\",\"type\":\"LinearAxis\"}],\"renderers\":[{\"id\":\"4216\",\"type\":\"LinearAxis\"},{\"id\":\"4220\",\"type\":\"Grid\"},{\"id\":\"4221\",\"type\":\"LinearAxis\"},{\"id\":\"4225\",\"type\":\"Grid\"},{\"id\":\"4234\",\"type\":\"BoxAnnotation\"},{\"id\":\"4244\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"4205\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"4232\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"4208\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"4212\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"4210\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"4214\",\"type\":\"LinearScale\"}},\"id\":\"4206\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"axis_label\":\"Month\",\"formatter\":{\"id\":\"4362\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"4206\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"4217\",\"type\":\"BasicTicker\"}},\"id\":\"4216\",\"type\":\"LinearAxis\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"4234\",\"type\":\"BoxAnnotation\"},{\"attributes\":{},\"id\":\"4217\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"4231\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"4230\",\"type\":\"ResetTool\"},{\"attributes\":{\"data_source\":{\"id\":\"4241\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"4242\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"4243\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"4245\",\"type\":\"CDSView\"}},\"id\":\"4244\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"source\":{\"id\":\"4241\",\"type\":\"ColumnDataSource\"}},\"id\":\"4245\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"4214\",\"type\":\"LinearScale\"},{\"attributes\":{\"overlay\":{\"id\":\"4234\",\"type\":\"BoxAnnotation\"}},\"id\":\"4228\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"4226\",\"type\":\"PanTool\"},{\"id\":\"4227\",\"type\":\"WheelZoomTool\"},{\"id\":\"4228\",\"type\":\"BoxZoomTool\"},{\"id\":\"4229\",\"type\":\"SaveTool\"},{\"id\":\"4230\",\"type\":\"ResetTool\"},{\"id\":\"4231\",\"type\":\"HelpTool\"}]},\"id\":\"4232\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"4212\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"4360\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"4362\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"axis_label\":\"Amount\",\"formatter\":{\"id\":\"4360\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"4206\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"4222\",\"type\":\"BasicTicker\"}},\"id\":\"4221\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"4364\",\"type\":\"UnionRenderers\"},{\"attributes\":{},\"id\":\"4229\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"4363\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"4226\",\"type\":\"PanTool\"},{\"attributes\":{\"callback\":null,\"data\":{\"x\":[2,3,5,6,8,9,10,11],\"y\":{\"__ndarray__\":\"AAAAJzPMmUAAAEDh+qauQAAAgCtcIbJAAAC+9dAw5UAAAAAhBYemQAAAiHYUlK1AAACAWw/ioEAAAMB4FECvQA==\",\"dtype\":\"float64\",\"shape\":[8]}},\"selected\":{\"id\":\"4363\",\"type\":\"Selection\"},\"selection_policy\":{\"id\":\"4364\",\"type\":\"UnionRenderers\"}},\"id\":\"4241\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"4206\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"4222\",\"type\":\"BasicTicker\"}},\"id\":\"4225\",\"type\":\"Grid\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#1f77b4\",\"line_width\":2,\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"4243\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"4222\",\"type\":\"BasicTicker\"},{\"attributes\":{\"callback\":null},\"id\":\"4210\",\"type\":\"DataRange1d\"},{\"attributes\":{\"plot\":null,\"text\":\"Sales overall (This year)\"},\"id\":\"4205\",\"type\":\"Title\"},{\"attributes\":{\"callback\":null},\"id\":\"4208\",\"type\":\"DataRange1d\"},{\"attributes\":{\"plot\":{\"id\":\"4206\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"4217\",\"type\":\"BasicTicker\"}},\"id\":\"4220\",\"type\":\"Grid\"},{\"attributes\":{\"line_color\":\"#1f77b4\",\"line_width\":2,\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"4242\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"4227\",\"type\":\"WheelZoomTool\"}],\"root_ids\":[\"4206\"]},\"title\":\"Bokeh Application\",\"version\":\"1.0.2\"}};\n",
" var render_items = [{\"docid\":\"3ed254b8-0528-4241-95dc-8013eb684571\",\"roots\":{\"4206\":\"504c11ce-54ad-405c-98d1-4435c8f4bcca\"}}];\n",
" root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
"\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" embed_document(root);\n",
" } else {\n",
" var attempts = 0;\n",
" var timer = setInterval(function(root) {\n",
" if (root.Bokeh !== undefined) {\n",
" embed_document(root);\n",
" clearInterval(timer);\n",
" }\n",
" attempts++;\n",
" if (attempts > 100) {\n",
" console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
" clearInterval(timer);\n",
" }\n",
" }, 10, root)\n",
" }\n",
"})(window);"
],
"application/vnd.bokehjs_exec.v0+json": ""
},
"metadata": {
"application/vnd.bokehjs_exec.v0+json": {
"id": "4206"
}
},
"output_type": "display_data"
}
],
"source": [
"df_this_year_overall = pd.read_json('http://35.240.46.26:5000/sales/last/year')\n",
"df_this_year_overall = df_this_year_overall[:-1] # remove this month\n",
"\n",
"p_this_year_overall = figure(title=\"Sales overall (This year)\", x_axis_label='Month', y_axis_label='Amount')\n",
"p_this_year_overall.line(df_this_year_overall.MONTH, df_this_year_overall.AMOUNT, line_width=2)\n",
"show(p_this_year_overall)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Sales overall (This month)"
]
},
{
"cell_type": "code",
"execution_count": 76,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" <div class=\"bk-root\" id=\"ecbe8f05-07f0-4c05-8d3e-890bf34ba549\"></div>\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"(function(root) {\n",
" function embed_document(root) {\n",
" \n",
" var docs_json = {\"02af6eae-a5da-4e6e-a68f-18510b84b848\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"4425\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"4430\",\"type\":\"LinearAxis\"}],\"renderers\":[{\"id\":\"4425\",\"type\":\"LinearAxis\"},{\"id\":\"4429\",\"type\":\"Grid\"},{\"id\":\"4430\",\"type\":\"LinearAxis\"},{\"id\":\"4434\",\"type\":\"Grid\"},{\"id\":\"4443\",\"type\":\"BoxAnnotation\"},{\"id\":\"4453\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"4414\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"4441\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"4417\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"4421\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"4419\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"4423\",\"type\":\"LinearScale\"}},\"id\":\"4415\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"axis_label\":\"Amount\",\"formatter\":{\"id\":\"4577\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"4415\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"4431\",\"type\":\"BasicTicker\"}},\"id\":\"4430\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"4577\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"4579\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"4435\",\"type\":\"PanTool\"},{\"attributes\":{},\"id\":\"4580\",\"type\":\"Selection\"},{\"attributes\":{\"data_source\":{\"id\":\"4450\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"4451\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"4452\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"4454\",\"type\":\"CDSView\"}},\"id\":\"4453\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"4581\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"line_color\":\"#1f77b4\",\"line_width\":2,\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"4451\",\"type\":\"Line\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"4443\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"callback\":null,\"data\":{\"x\":[10],\"y\":{\"__ndarray__\":\"HBe9aXPohEE=\",\"dtype\":\"float64\",\"shape\":[1]}},\"selected\":{\"id\":\"4580\",\"type\":\"Selection\"},\"selection_policy\":{\"id\":\"4581\",\"type\":\"UnionRenderers\"}},\"id\":\"4450\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"4435\",\"type\":\"PanTool\"},{\"id\":\"4436\",\"type\":\"WheelZoomTool\"},{\"id\":\"4437\",\"type\":\"BoxZoomTool\"},{\"id\":\"4438\",\"type\":\"SaveTool\"},{\"id\":\"4439\",\"type\":\"ResetTool\"},{\"id\":\"4440\",\"type\":\"HelpTool\"}]},\"id\":\"4441\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"4436\",\"type\":\"WheelZoomTool\"},{\"attributes\":{},\"id\":\"4438\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"4440\",\"type\":\"HelpTool\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"4415\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"4431\",\"type\":\"BasicTicker\"}},\"id\":\"4434\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"4439\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"4423\",\"type\":\"LinearScale\"},{\"attributes\":{\"source\":{\"id\":\"4450\",\"type\":\"ColumnDataSource\"}},\"id\":\"4454\",\"type\":\"CDSView\"},{\"attributes\":{\"axis_label\":\"Date\",\"formatter\":{\"id\":\"4579\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"4415\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"4426\",\"type\":\"BasicTicker\"}},\"id\":\"4425\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"4431\",\"type\":\"BasicTicker\"},{\"attributes\":{\"overlay\":{\"id\":\"4443\",\"type\":\"BoxAnnotation\"}},\"id\":\"4437\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"plot\":null,\"text\":\"Sales overall (This month)\"},\"id\":\"4414\",\"type\":\"Title\"},{\"attributes\":{},\"id\":\"4421\",\"type\":\"LinearScale\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#1f77b4\",\"line_width\":2,\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"4452\",\"type\":\"Line\"},{\"attributes\":{\"plot\":{\"id\":\"4415\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"4426\",\"type\":\"BasicTicker\"}},\"id\":\"4429\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"4426\",\"type\":\"BasicTicker\"},{\"attributes\":{\"callback\":null},\"id\":\"4417\",\"type\":\"DataRange1d\"},{\"attributes\":{\"callback\":null},\"id\":\"4419\",\"type\":\"DataRange1d\"}],\"root_ids\":[\"4415\"]},\"title\":\"Bokeh Application\",\"version\":\"1.0.2\"}};\n",
" var render_items = [{\"docid\":\"02af6eae-a5da-4e6e-a68f-18510b84b848\",\"roots\":{\"4415\":\"ecbe8f05-07f0-4c05-8d3e-890bf34ba549\"}}];\n",
" root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
"\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" embed_document(root);\n",
" } else {\n",
" var attempts = 0;\n",
" var timer = setInterval(function(root) {\n",
" if (root.Bokeh !== undefined) {\n",
" embed_document(root);\n",
" clearInterval(timer);\n",
" }\n",
" attempts++;\n",
" if (attempts > 100) {\n",
" console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
" clearInterval(timer);\n",
" }\n",
" }, 10, root)\n",
" }\n",
"})(window);"
],
"application/vnd.bokehjs_exec.v0+json": ""
},
"metadata": {
"application/vnd.bokehjs_exec.v0+json": {
"id": "4415"
}
},
"output_type": "display_data"
}
],
"source": [
"df_this_month_overall = pd.read_json('http://35.240.46.26:5000/sales/last/month')\n",
"\n",
"p_this_month_overall = figure(title=\"Sales overall (This month)\", x_axis_label='Date', y_axis_label='Amount')\n",
"p_this_month_overall.line(df_this_month_overall.DATE, df_this_month_overall.AMOUNT, line_width=2)\n",
"show(p_this_month_overall)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Sales overall (Today)"
]
},
{
"cell_type": "code",
"execution_count": 77,
"metadata": {},
"outputs": [
{
"ename": "AttributeError",
"evalue": "'DataFrame' object has no attribute 'TIME'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-77-1b3ba560a30f>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mp_today_overall\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfigure\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtitle\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"Sales overall (This month)\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mx_axis_label\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'Time'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my_axis_label\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'Amount'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0mp_today_overall\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mline\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdf_today_overall\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mTIME\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdf_today_overall\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mAMOUNT\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mline_width\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 5\u001b[0m \u001b[0mshow\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mp_today_overall\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/anaconda2/envs/data-mining/lib/python3.6/site-packages/pandas/core/generic.py\u001b[0m in \u001b[0;36m__getattr__\u001b[0;34m(self, name)\u001b[0m\n\u001b[1;32m 4374\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_info_axis\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_can_hold_identifiers_and_holds_name\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4375\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 4376\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mobject\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__getattribute__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4377\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4378\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__setattr__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mAttributeError\u001b[0m: 'DataFrame' object has no attribute 'TIME'"
]
}
],
"source": [
"df_today_overall = pd.read_json('http://35.240.46.26:5000/sales/last/day')\n",
"\n",
"p_today_overall = figure(title=\"Sales overall (This month)\", x_axis_label='Time', y_axis_label='Amount')\n",
"p_today_overall.line(df_today_overall.TIME, df_today_overall.AMOUNT, line_width=2)\n",
"show(p_today_overall)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"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.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment