Spaces:
Running
Running
Add scipy to requirements.txt and refactor data visualization in app.py
Browse files- app.ipynb +27 -30
- app.py +12 -15
- helpers/__init__.py +0 -0
- helpers/__pycache__/__init__.cpython-311.pyc +0 -0
- helpers/__pycache__/utils.cpython-311.pyc +0 -0
- helpers/utils.py +122 -0
- requirements.txt +1 -0
app.ipynb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
"cells": [
|
| 3 |
{
|
| 4 |
"cell_type": "code",
|
| 5 |
-
"execution_count":
|
| 6 |
"metadata": {},
|
| 7 |
"outputs": [
|
| 8 |
{
|
|
@@ -98,7 +98,7 @@
|
|
| 98 |
},
|
| 99 |
{
|
| 100 |
"cell_type": "code",
|
| 101 |
-
"execution_count":
|
| 102 |
"metadata": {},
|
| 103 |
"outputs": [],
|
| 104 |
"source": [
|
|
@@ -109,17 +109,18 @@
|
|
| 109 |
"import pandas as pd\n",
|
| 110 |
"import numpy as np\n",
|
| 111 |
"import io\n",
|
|
|
|
| 112 |
"\n"
|
| 113 |
]
|
| 114 |
},
|
| 115 |
{
|
| 116 |
"cell_type": "code",
|
| 117 |
-
"execution_count":
|
| 118 |
"metadata": {},
|
| 119 |
"outputs": [
|
| 120 |
{
|
| 121 |
"data": {
|
| 122 |
-
"application/javascript": "(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n var py_version = '3.3.4'.replace('rc', '-rc.').replace('.dev', '-dev.');\n var reloading = true;\n var Bokeh = root.Bokeh;\n\n if (typeof (root._bokeh_timeout) === \"undefined\" || force) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks;\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, js_modules, js_exports, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n if (js_modules == null) js_modules = [];\n if (js_exports == null) js_exports = {};\n\n root._bokeh_onload_callbacks.push(callback);\n\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls.length === 0 && js_modules.length === 0 && Object.keys(js_exports).length === 0) {\n run_callbacks();\n return null;\n }\n if (!reloading) {\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n }\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n window._bokeh_on_load = on_load\n\n function on_error() {\n console.error(\"failed to load \" + url);\n }\n\n var skip = [];\n if (window.requirejs) {\n window.requirejs.config({'packages': {}, 'paths': {'jspanel': 'https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/jspanel', 'jspanel-modal': 'https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/extensions/modal/jspanel.modal', 'jspanel-tooltip': 'https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/extensions/tooltip/jspanel.tooltip', 'jspanel-hint': 'https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/extensions/hint/jspanel.hint', 'jspanel-layout': 'https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/extensions/layout/jspanel.layout', 'jspanel-contextmenu': 'https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/extensions/contextmenu/jspanel.contextmenu', 'jspanel-dock': 'https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/extensions/dock/jspanel.dock', 'gridstack': 'https://cdn.jsdelivr.net/npm/gridstack@7.2.3/dist/gridstack-all', 'notyf': 'https://cdn.jsdelivr.net/npm/notyf@3/notyf.min'}, 'shim': {'jspanel': {'exports': 'jsPanel'}, 'gridstack': {'exports': 'GridStack'}}});\n require([\"jspanel\"], function(jsPanel) {\n\twindow.jsPanel = jsPanel\n\ton_load()\n })\n require([\"jspanel-modal\"], function() {\n\ton_load()\n })\n require([\"jspanel-tooltip\"], function() {\n\ton_load()\n })\n require([\"jspanel-hint\"], function() {\n\ton_load()\n })\n require([\"jspanel-layout\"], function() {\n\ton_load()\n })\n require([\"jspanel-contextmenu\"], function() {\n\ton_load()\n })\n require([\"jspanel-dock\"], function() {\n\ton_load()\n })\n require([\"gridstack\"], function(GridStack) {\n\twindow.GridStack = GridStack\n\ton_load()\n })\n require([\"notyf\"], function() {\n\ton_load()\n })\n root._bokeh_is_loading = css_urls.length + 9;\n } else {\n root._bokeh_is_loading = css_urls.length + js_urls.length + js_modules.length + Object.keys(js_exports).length;\n }\n\n var existing_stylesheets = []\n var links = document.getElementsByTagName('link')\n for (var i = 0; i < links.length; i++) {\n var link = links[i]\n if (link.href != null) {\n\texisting_stylesheets.push(link.href)\n }\n }\n for (var i = 0; i < css_urls.length; i++) {\n var url = css_urls[i];\n if (existing_stylesheets.indexOf(url) !== -1) {\n\ton_load()\n\tcontinue;\n }\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error;\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n } if (((window['jsPanel'] !== undefined) && (!(window['jsPanel'] instanceof HTMLElement))) || window.requirejs) {\n var urls = ['https://cdn.holoviz.org/panel/1.3.8/dist/bundled/floatpanel/jspanel4@4.12.0/dist/jspanel.js', 'https://cdn.holoviz.org/panel/1.3.8/dist/bundled/floatpanel/jspanel4@4.12.0/dist/extensions/modal/jspanel.modal.js', 'https://cdn.holoviz.org/panel/1.3.8/dist/bundled/floatpanel/jspanel4@4.12.0/dist/extensions/tooltip/jspanel.tooltip.js', 'https://cdn.holoviz.org/panel/1.3.8/dist/bundled/floatpanel/jspanel4@4.12.0/dist/extensions/hint/jspanel.hint.js', 'https://cdn.holoviz.org/panel/1.3.8/dist/bundled/floatpanel/jspanel4@4.12.0/dist/extensions/layout/jspanel.layout.js', 'https://cdn.holoviz.org/panel/1.3.8/dist/bundled/floatpanel/jspanel4@4.12.0/dist/extensions/contextmenu/jspanel.contextmenu.js', 'https://cdn.holoviz.org/panel/1.3.8/dist/bundled/floatpanel/jspanel4@4.12.0/dist/extensions/dock/jspanel.dock.js'];\n for (var i = 0; i < urls.length; i++) {\n skip.push(urls[i])\n }\n } if (((window['GridStack'] !== undefined) && (!(window['GridStack'] instanceof HTMLElement))) || window.requirejs) {\n var urls = ['https://cdn.holoviz.org/panel/1.3.8/dist/bundled/gridstack/gridstack@7.2.3/dist/gridstack-all.js'];\n for (var i = 0; i < urls.length; i++) {\n skip.push(urls[i])\n }\n } if (((window['Notyf'] !== undefined) && (!(window['Notyf'] instanceof HTMLElement))) || window.requirejs) {\n var urls = ['https://cdn.holoviz.org/panel/1.3.8/dist/bundled/notificationarea/notyf@3/notyf.min.js'];\n for (var i = 0; i < urls.length; i++) {\n skip.push(urls[i])\n }\n } var existing_scripts = []\n var scripts = document.getElementsByTagName('script')\n for (var i = 0; i < scripts.length; i++) {\n var script = scripts[i]\n if (script.src != null) {\n\texisting_scripts.push(script.src)\n }\n }\n for (var i = 0; i < js_urls.length; i++) {\n var url = js_urls[i];\n if (skip.indexOf(url) !== -1 || existing_scripts.indexOf(url) !== -1) {\n\tif (!window.requirejs) {\n\t on_load();\n\t}\n\tcontinue;\n }\n var element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n for (var i = 0; i < js_modules.length; i++) {\n var url = js_modules[i];\n if (skip.indexOf(url) !== -1 || existing_scripts.indexOf(url) !== -1) {\n\tif (!window.requirejs) {\n\t on_load();\n\t}\n\tcontinue;\n }\n var element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n element.type = \"module\";\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n for (const name in js_exports) {\n var url = js_exports[name];\n if (skip.indexOf(url) >= 0 || root[name] != null) {\n\tif (!window.requirejs) {\n\t on_load();\n\t}\n\tcontinue;\n }\n var element = document.createElement('script');\n element.onerror = on_error;\n element.async = false;\n element.type = \"module\";\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n element.textContent = `\n import ${name} from \"${url}\"\n window.${name} = ${name}\n window._bokeh_on_load()\n `\n document.head.appendChild(element);\n }\n if (!js_urls.length && !js_modules.length) {\n on_load()\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n var js_urls = [\"https://cdn.holoviz.org/panel/1.3.8/dist/bundled/material-components-web@7.0.0/dist/material-components-web.min.js\"];\n var js_modules = [];\n var js_exports = {};\n var css_urls = [\"https://fonts.googleapis.com/css?family=Roboto:300,400,500\", \"https://fonts.googleapis.com/css?family=Material+Icons&display=block\"];\n var inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {} // ensure no trailing comma for IE\n ];\n\n function run_inline_js() {\n if ((root.Bokeh !== undefined) || (force === true)) {\n for (var i = 0; i < inline_js.length; i++) {\n\ttry {\n inline_js[i].call(root, root.Bokeh);\n\t} catch(e) {\n\t if (!reloading) {\n\t throw e;\n\t }\n\t}\n }\n // Cache old bokeh versions\n if (Bokeh != undefined && !reloading) {\n\tvar NewBokeh = root.Bokeh;\n\tif (Bokeh.versions === undefined) {\n\t Bokeh.versions = new Map();\n\t}\n\tif (NewBokeh.version !== Bokeh.version) {\n\t Bokeh.versions.set(NewBokeh.version, NewBokeh)\n\t}\n\troot.Bokeh = Bokeh;\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 }\n root._bokeh_is_initializing = false\n }\n\n function load_or_wait() {\n // Implement a backoff loop that tries to ensure we do not load multiple\n // versions of Bokeh and its dependencies at the same time.\n // In recent versions we use the root._bokeh_is_initializing flag\n // to determine whether there is an ongoing attempt to initialize\n // bokeh, however for backward compatibility we also try to ensure\n // that we do not start loading a newer (Panel>=1.0 and Bokeh>3) version\n // before older versions are fully initialized.\n if (root._bokeh_is_initializing && Date.now() > root._bokeh_timeout) {\n root._bokeh_is_initializing = false;\n root._bokeh_onload_callbacks = undefined;\n console.log(\"Bokeh: BokehJS was loaded multiple times but one version failed to initialize.\");\n load_or_wait();\n } else if (root._bokeh_is_initializing || (typeof root._bokeh_is_initializing === \"undefined\" && root._bokeh_onload_callbacks !== undefined)) {\n setTimeout(load_or_wait, 100);\n } else {\n root._bokeh_is_initializing = true\n root._bokeh_onload_callbacks = []\n var bokeh_loaded = Bokeh != null && (Bokeh.version === py_version || (Bokeh.versions !== undefined && Bokeh.versions.has(py_version)));\n if (!reloading && !bokeh_loaded) {\n\troot.Bokeh = undefined;\n }\n load_libs(css_urls, js_urls, js_modules, js_exports, function() {\n\tconsole.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n\trun_inline_js();\n });\n }\n }\n // Give older versions of the autoload script a head-start to ensure\n // they initialize before we start loading newer version.\n setTimeout(load_or_wait, 100)\n}(window));",
|
| 123 |
"application/vnd.holoviews_load.v0+json": ""
|
| 124 |
},
|
| 125 |
"metadata": {},
|
|
@@ -161,12 +162,12 @@
|
|
| 161 |
"data": {
|
| 162 |
"application/vnd.holoviews_exec.v0+json": "",
|
| 163 |
"text/html": [
|
| 164 |
-
"<div id='
|
| 165 |
-
" <div id=\"
|
| 166 |
"</div>\n",
|
| 167 |
"<script type=\"application/javascript\">(function(root) {\n",
|
| 168 |
-
" var docs_json = {\"
|
| 169 |
-
" var render_items = [{\"docid\":\"
|
| 170 |
" var docs = Object.values(docs_json)\n",
|
| 171 |
" if (!docs) {\n",
|
| 172 |
" return\n",
|
|
@@ -230,7 +231,7 @@
|
|
| 230 |
},
|
| 231 |
"metadata": {
|
| 232 |
"application/vnd.holoviews_exec.v0+json": {
|
| 233 |
-
"id": "
|
| 234 |
}
|
| 235 |
},
|
| 236 |
"output_type": "display_data"
|
|
@@ -254,7 +255,7 @@
|
|
| 254 |
},
|
| 255 |
{
|
| 256 |
"cell_type": "code",
|
| 257 |
-
"execution_count":
|
| 258 |
"metadata": {},
|
| 259 |
"outputs": [],
|
| 260 |
"source": [
|
|
@@ -278,7 +279,7 @@
|
|
| 278 |
},
|
| 279 |
{
|
| 280 |
"cell_type": "code",
|
| 281 |
-
"execution_count":
|
| 282 |
"metadata": {},
|
| 283 |
"outputs": [],
|
| 284 |
"source": [
|
|
@@ -292,7 +293,7 @@
|
|
| 292 |
},
|
| 293 |
{
|
| 294 |
"cell_type": "code",
|
| 295 |
-
"execution_count":
|
| 296 |
"metadata": {},
|
| 297 |
"outputs": [],
|
| 298 |
"source": [
|
|
@@ -306,23 +307,19 @@
|
|
| 306 |
" if file is None:\n",
|
| 307 |
" return \"No file selected\"\n",
|
| 308 |
" df = pd.read_csv(io.BytesIO(file))\n",
|
| 309 |
-
" \n",
|
| 310 |
-
" widget = pn.Column(\n",
|
| 311 |
-
" pn.pane.Markdown(\n",
|
| 312 |
-
" \"\"\"\n",
|
| 313 |
-
" ## Data Preview\n",
|
| 314 |
-
"\n",
|
| 315 |
-
" Here is a preview of the data.\n",
|
| 316 |
-
" \"\"\"\n",
|
| 317 |
-
" ),\n",
|
| 318 |
-
" pn.pane.Markdown(f\"### Data Shape: {df.shape}\"),\n",
|
| 319 |
-
" pn.pane.Markdown(f\"### Data Head\"),\n",
|
| 320 |
-
" pn.pane.DataFrame(df.head(5)),\n",
|
| 321 |
-
" pn.pane.Markdown(f\"### Describe\"),\n",
|
| 322 |
-
" pn.pane.DataFrame(df.describe()),\n",
|
| 323 |
" \n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 324 |
" )\n",
|
| 325 |
-
" return widget\n",
|
| 326 |
" \n",
|
| 327 |
"\n",
|
| 328 |
"bound_data = pn.bind(get_data, switch=switch, url=url, file=file)\n",
|
|
@@ -336,7 +333,7 @@
|
|
| 336 |
},
|
| 337 |
{
|
| 338 |
"cell_type": "code",
|
| 339 |
-
"execution_count":
|
| 340 |
"metadata": {},
|
| 341 |
"outputs": [],
|
| 342 |
"source": [
|
|
@@ -345,7 +342,7 @@
|
|
| 345 |
},
|
| 346 |
{
|
| 347 |
"cell_type": "code",
|
| 348 |
-
"execution_count":
|
| 349 |
"metadata": {},
|
| 350 |
"outputs": [],
|
| 351 |
"source": [
|
|
@@ -360,7 +357,7 @@
|
|
| 360 |
},
|
| 361 |
{
|
| 362 |
"cell_type": "code",
|
| 363 |
-
"execution_count":
|
| 364 |
"metadata": {},
|
| 365 |
"outputs": [],
|
| 366 |
"source": [
|
|
|
|
| 2 |
"cells": [
|
| 3 |
{
|
| 4 |
"cell_type": "code",
|
| 5 |
+
"execution_count": 10,
|
| 6 |
"metadata": {},
|
| 7 |
"outputs": [
|
| 8 |
{
|
|
|
|
| 98 |
},
|
| 99 |
{
|
| 100 |
"cell_type": "code",
|
| 101 |
+
"execution_count": 11,
|
| 102 |
"metadata": {},
|
| 103 |
"outputs": [],
|
| 104 |
"source": [
|
|
|
|
| 109 |
"import pandas as pd\n",
|
| 110 |
"import numpy as np\n",
|
| 111 |
"import io\n",
|
| 112 |
+
"import helpers.utils as utils\n",
|
| 113 |
"\n"
|
| 114 |
]
|
| 115 |
},
|
| 116 |
{
|
| 117 |
"cell_type": "code",
|
| 118 |
+
"execution_count": 12,
|
| 119 |
"metadata": {},
|
| 120 |
"outputs": [
|
| 121 |
{
|
| 122 |
"data": {
|
| 123 |
+
"application/javascript": "(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n var py_version = '3.3.4'.replace('rc', '-rc.').replace('.dev', '-dev.');\n var reloading = true;\n var Bokeh = root.Bokeh;\n\n if (typeof (root._bokeh_timeout) === \"undefined\" || force) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks;\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, js_modules, js_exports, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n if (js_modules == null) js_modules = [];\n if (js_exports == null) js_exports = {};\n\n root._bokeh_onload_callbacks.push(callback);\n\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls.length === 0 && js_modules.length === 0 && Object.keys(js_exports).length === 0) {\n run_callbacks();\n return null;\n }\n if (!reloading) {\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n }\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n window._bokeh_on_load = on_load\n\n function on_error() {\n console.error(\"failed to load \" + url);\n }\n\n var skip = [];\n if (window.requirejs) {\n window.requirejs.config({'packages': {}, 'paths': {'jspanel': 'https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/jspanel', 'jspanel-modal': 'https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/extensions/modal/jspanel.modal', 'jspanel-tooltip': 'https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/extensions/tooltip/jspanel.tooltip', 'jspanel-hint': 'https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/extensions/hint/jspanel.hint', 'jspanel-layout': 'https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/extensions/layout/jspanel.layout', 'jspanel-contextmenu': 'https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/extensions/contextmenu/jspanel.contextmenu', 'jspanel-dock': 'https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/extensions/dock/jspanel.dock', 'gridstack': 'https://cdn.jsdelivr.net/npm/gridstack@7.2.3/dist/gridstack-all', 'notyf': 'https://cdn.jsdelivr.net/npm/notyf@3/notyf.min'}, 'shim': {'jspanel': {'exports': 'jsPanel'}, 'gridstack': {'exports': 'GridStack'}}});\n require([\"jspanel\"], function(jsPanel) {\n\twindow.jsPanel = jsPanel\n\ton_load()\n })\n require([\"jspanel-modal\"], function() {\n\ton_load()\n })\n require([\"jspanel-tooltip\"], function() {\n\ton_load()\n })\n require([\"jspanel-hint\"], function() {\n\ton_load()\n })\n require([\"jspanel-layout\"], function() {\n\ton_load()\n })\n require([\"jspanel-contextmenu\"], function() {\n\ton_load()\n })\n require([\"jspanel-dock\"], function() {\n\ton_load()\n })\n require([\"gridstack\"], function(GridStack) {\n\twindow.GridStack = GridStack\n\ton_load()\n })\n require([\"notyf\"], function() {\n\ton_load()\n })\n root._bokeh_is_loading = css_urls.length + 9;\n } else {\n root._bokeh_is_loading = css_urls.length + js_urls.length + js_modules.length + Object.keys(js_exports).length;\n }\n\n var existing_stylesheets = []\n var links = document.getElementsByTagName('link')\n for (var i = 0; i < links.length; i++) {\n var link = links[i]\n if (link.href != null) {\n\texisting_stylesheets.push(link.href)\n }\n }\n for (var i = 0; i < css_urls.length; i++) {\n var url = css_urls[i];\n if (existing_stylesheets.indexOf(url) !== -1) {\n\ton_load()\n\tcontinue;\n }\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error;\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n } if (((window['jsPanel'] !== undefined) && (!(window['jsPanel'] instanceof HTMLElement))) || window.requirejs) {\n var urls = ['https://cdn.holoviz.org/panel/1.3.8/dist/bundled/floatpanel/jspanel4@4.12.0/dist/jspanel.js', 'https://cdn.holoviz.org/panel/1.3.8/dist/bundled/floatpanel/jspanel4@4.12.0/dist/extensions/modal/jspanel.modal.js', 'https://cdn.holoviz.org/panel/1.3.8/dist/bundled/floatpanel/jspanel4@4.12.0/dist/extensions/tooltip/jspanel.tooltip.js', 'https://cdn.holoviz.org/panel/1.3.8/dist/bundled/floatpanel/jspanel4@4.12.0/dist/extensions/hint/jspanel.hint.js', 'https://cdn.holoviz.org/panel/1.3.8/dist/bundled/floatpanel/jspanel4@4.12.0/dist/extensions/layout/jspanel.layout.js', 'https://cdn.holoviz.org/panel/1.3.8/dist/bundled/floatpanel/jspanel4@4.12.0/dist/extensions/contextmenu/jspanel.contextmenu.js', 'https://cdn.holoviz.org/panel/1.3.8/dist/bundled/floatpanel/jspanel4@4.12.0/dist/extensions/dock/jspanel.dock.js'];\n for (var i = 0; i < urls.length; i++) {\n skip.push(urls[i])\n }\n } if (((window['GridStack'] !== undefined) && (!(window['GridStack'] instanceof HTMLElement))) || window.requirejs) {\n var urls = ['https://cdn.holoviz.org/panel/1.3.8/dist/bundled/gridstack/gridstack@7.2.3/dist/gridstack-all.js'];\n for (var i = 0; i < urls.length; i++) {\n skip.push(urls[i])\n }\n } if (((window['Notyf'] !== undefined) && (!(window['Notyf'] instanceof HTMLElement))) || window.requirejs) {\n var urls = ['https://cdn.holoviz.org/panel/1.3.8/dist/bundled/notificationarea/notyf@3/notyf.min.js'];\n for (var i = 0; i < urls.length; i++) {\n skip.push(urls[i])\n }\n } var existing_scripts = []\n var scripts = document.getElementsByTagName('script')\n for (var i = 0; i < scripts.length; i++) {\n var script = scripts[i]\n if (script.src != null) {\n\texisting_scripts.push(script.src)\n }\n }\n for (var i = 0; i < js_urls.length; i++) {\n var url = js_urls[i];\n if (skip.indexOf(url) !== -1 || existing_scripts.indexOf(url) !== -1) {\n\tif (!window.requirejs) {\n\t on_load();\n\t}\n\tcontinue;\n }\n var element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n for (var i = 0; i < js_modules.length; i++) {\n var url = js_modules[i];\n if (skip.indexOf(url) !== -1 || existing_scripts.indexOf(url) !== -1) {\n\tif (!window.requirejs) {\n\t on_load();\n\t}\n\tcontinue;\n }\n var element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n element.type = \"module\";\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n for (const name in js_exports) {\n var url = js_exports[name];\n if (skip.indexOf(url) >= 0 || root[name] != null) {\n\tif (!window.requirejs) {\n\t on_load();\n\t}\n\tcontinue;\n }\n var element = document.createElement('script');\n element.onerror = on_error;\n element.async = false;\n element.type = \"module\";\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n element.textContent = `\n import ${name} from \"${url}\"\n window.${name} = ${name}\n window._bokeh_on_load()\n `\n document.head.appendChild(element);\n }\n if (!js_urls.length && !js_modules.length) {\n on_load()\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n var js_urls = [];\n var js_modules = [];\n var js_exports = {};\n var css_urls = [];\n var inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {} // ensure no trailing comma for IE\n ];\n\n function run_inline_js() {\n if ((root.Bokeh !== undefined) || (force === true)) {\n for (var i = 0; i < inline_js.length; i++) {\n\ttry {\n inline_js[i].call(root, root.Bokeh);\n\t} catch(e) {\n\t if (!reloading) {\n\t throw e;\n\t }\n\t}\n }\n // Cache old bokeh versions\n if (Bokeh != undefined && !reloading) {\n\tvar NewBokeh = root.Bokeh;\n\tif (Bokeh.versions === undefined) {\n\t Bokeh.versions = new Map();\n\t}\n\tif (NewBokeh.version !== Bokeh.version) {\n\t Bokeh.versions.set(NewBokeh.version, NewBokeh)\n\t}\n\troot.Bokeh = Bokeh;\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 }\n root._bokeh_is_initializing = false\n }\n\n function load_or_wait() {\n // Implement a backoff loop that tries to ensure we do not load multiple\n // versions of Bokeh and its dependencies at the same time.\n // In recent versions we use the root._bokeh_is_initializing flag\n // to determine whether there is an ongoing attempt to initialize\n // bokeh, however for backward compatibility we also try to ensure\n // that we do not start loading a newer (Panel>=1.0 and Bokeh>3) version\n // before older versions are fully initialized.\n if (root._bokeh_is_initializing && Date.now() > root._bokeh_timeout) {\n root._bokeh_is_initializing = false;\n root._bokeh_onload_callbacks = undefined;\n console.log(\"Bokeh: BokehJS was loaded multiple times but one version failed to initialize.\");\n load_or_wait();\n } else if (root._bokeh_is_initializing || (typeof root._bokeh_is_initializing === \"undefined\" && root._bokeh_onload_callbacks !== undefined)) {\n setTimeout(load_or_wait, 100);\n } else {\n root._bokeh_is_initializing = true\n root._bokeh_onload_callbacks = []\n var bokeh_loaded = Bokeh != null && (Bokeh.version === py_version || (Bokeh.versions !== undefined && Bokeh.versions.has(py_version)));\n if (!reloading && !bokeh_loaded) {\n\troot.Bokeh = undefined;\n }\n load_libs(css_urls, js_urls, js_modules, js_exports, function() {\n\tconsole.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n\trun_inline_js();\n });\n }\n }\n // Give older versions of the autoload script a head-start to ensure\n // they initialize before we start loading newer version.\n setTimeout(load_or_wait, 100)\n}(window));",
|
| 124 |
"application/vnd.holoviews_load.v0+json": ""
|
| 125 |
},
|
| 126 |
"metadata": {},
|
|
|
|
| 162 |
"data": {
|
| 163 |
"application/vnd.holoviews_exec.v0+json": "",
|
| 164 |
"text/html": [
|
| 165 |
+
"<div id='1abf19e8-c829-4091-925a-9114dd4220aa'>\n",
|
| 166 |
+
" <div id=\"ce3ddf3d-c57f-400b-acb4-f4d3c8688f2e\" data-root-id=\"1abf19e8-c829-4091-925a-9114dd4220aa\" style=\"display: contents;\"></div>\n",
|
| 167 |
"</div>\n",
|
| 168 |
"<script type=\"application/javascript\">(function(root) {\n",
|
| 169 |
+
" var docs_json = {\"213b43a3-1f08-4198-a068-6908f1b8f385\":{\"version\":\"3.3.4\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"panel.models.browser.BrowserInfo\",\"id\":\"1abf19e8-c829-4091-925a-9114dd4220aa\"},{\"type\":\"object\",\"name\":\"panel.models.comm_manager.CommManager\",\"id\":\"0ce6c4ec-81ab-4d4a-9a0c-b4464e91c9e2\",\"attributes\":{\"plot_id\":\"1abf19e8-c829-4091-925a-9114dd4220aa\",\"comm_id\":\"6f1d04e503a1442c93729ca12d6088f8\",\"client_comm_id\":\"121fc28050f44e2b8fad4362e3d57201\"}}],\"defs\":[{\"type\":\"model\",\"name\":\"ReactiveHTML1\"},{\"type\":\"model\",\"name\":\"FlexBox1\",\"properties\":[{\"name\":\"align_content\",\"kind\":\"Any\",\"default\":\"flex-start\"},{\"name\":\"align_items\",\"kind\":\"Any\",\"default\":\"flex-start\"},{\"name\":\"flex_direction\",\"kind\":\"Any\",\"default\":\"row\"},{\"name\":\"flex_wrap\",\"kind\":\"Any\",\"default\":\"wrap\"},{\"name\":\"justify_content\",\"kind\":\"Any\",\"default\":\"flex-start\"}]},{\"type\":\"model\",\"name\":\"FloatPanel1\",\"properties\":[{\"name\":\"config\",\"kind\":\"Any\",\"default\":{\"type\":\"map\"}},{\"name\":\"contained\",\"kind\":\"Any\",\"default\":true},{\"name\":\"position\",\"kind\":\"Any\",\"default\":\"right-top\"},{\"name\":\"offsetx\",\"kind\":\"Any\",\"default\":null},{\"name\":\"offsety\",\"kind\":\"Any\",\"default\":null},{\"name\":\"theme\",\"kind\":\"Any\",\"default\":\"primary\"},{\"name\":\"status\",\"kind\":\"Any\",\"default\":\"normalized\"}]},{\"type\":\"model\",\"name\":\"GridStack1\",\"properties\":[{\"name\":\"mode\",\"kind\":\"Any\",\"default\":\"warn\"},{\"name\":\"ncols\",\"kind\":\"Any\",\"default\":null},{\"name\":\"nrows\",\"kind\":\"Any\",\"default\":null},{\"name\":\"allow_resize\",\"kind\":\"Any\",\"default\":true},{\"name\":\"allow_drag\",\"kind\":\"Any\",\"default\":true},{\"name\":\"state\",\"kind\":\"Any\",\"default\":[]}]},{\"type\":\"model\",\"name\":\"drag1\",\"properties\":[{\"name\":\"slider_width\",\"kind\":\"Any\",\"default\":5},{\"name\":\"slider_color\",\"kind\":\"Any\",\"default\":\"black\"},{\"name\":\"value\",\"kind\":\"Any\",\"default\":50}]},{\"type\":\"model\",\"name\":\"click1\",\"properties\":[{\"name\":\"terminal_output\",\"kind\":\"Any\",\"default\":\"\"},{\"name\":\"debug_name\",\"kind\":\"Any\",\"default\":\"\"},{\"name\":\"clears\",\"kind\":\"Any\",\"default\":0}]},{\"type\":\"model\",\"name\":\"copy_to_clipboard1\",\"properties\":[{\"name\":\"fill\",\"kind\":\"Any\",\"default\":\"none\"},{\"name\":\"value\",\"kind\":\"Any\",\"default\":null}]},{\"type\":\"model\",\"name\":\"FastWrapper1\",\"properties\":[{\"name\":\"object\",\"kind\":\"Any\",\"default\":null},{\"name\":\"style\",\"kind\":\"Any\",\"default\":null}]},{\"type\":\"model\",\"name\":\"NotificationAreaBase1\",\"properties\":[{\"name\":\"js_events\",\"kind\":\"Any\",\"default\":{\"type\":\"map\"}},{\"name\":\"position\",\"kind\":\"Any\",\"default\":\"bottom-right\"},{\"name\":\"_clear\",\"kind\":\"Any\",\"default\":0}]},{\"type\":\"model\",\"name\":\"NotificationArea1\",\"properties\":[{\"name\":\"js_events\",\"kind\":\"Any\",\"default\":{\"type\":\"map\"}},{\"name\":\"notifications\",\"kind\":\"Any\",\"default\":[]},{\"name\":\"position\",\"kind\":\"Any\",\"default\":\"bottom-right\"},{\"name\":\"_clear\",\"kind\":\"Any\",\"default\":0},{\"name\":\"types\",\"kind\":\"Any\",\"default\":[{\"type\":\"map\",\"entries\":[[\"type\",\"warning\"],[\"background\",\"#ffc107\"],[\"icon\",{\"type\":\"map\",\"entries\":[[\"className\",\"fas fa-exclamation-triangle\"],[\"tagName\",\"i\"],[\"color\",\"white\"]]}]]},{\"type\":\"map\",\"entries\":[[\"type\",\"info\"],[\"background\",\"#007bff\"],[\"icon\",{\"type\":\"map\",\"entries\":[[\"className\",\"fas fa-info-circle\"],[\"tagName\",\"i\"],[\"color\",\"white\"]]}]]}]}]},{\"type\":\"model\",\"name\":\"Notification\",\"properties\":[{\"name\":\"background\",\"kind\":\"Any\",\"default\":null},{\"name\":\"duration\",\"kind\":\"Any\",\"default\":3000},{\"name\":\"icon\",\"kind\":\"Any\",\"default\":null},{\"name\":\"message\",\"kind\":\"Any\",\"default\":\"\"},{\"name\":\"notification_type\",\"kind\":\"Any\",\"default\":null},{\"name\":\"_destroyed\",\"kind\":\"Any\",\"default\":false}]},{\"type\":\"model\",\"name\":\"TemplateActions1\",\"properties\":[{\"name\":\"open_modal\",\"kind\":\"Any\",\"default\":0},{\"name\":\"close_modal\",\"kind\":\"Any\",\"default\":0}]},{\"type\":\"model\",\"name\":\"BootstrapTemplateActions1\",\"properties\":[{\"name\":\"open_modal\",\"kind\":\"Any\",\"default\":0},{\"name\":\"close_modal\",\"kind\":\"Any\",\"default\":0}]},{\"type\":\"model\",\"name\":\"MaterialTemplateActions1\",\"properties\":[{\"name\":\"open_modal\",\"kind\":\"Any\",\"default\":0},{\"name\":\"close_modal\",\"kind\":\"Any\",\"default\":0}]}]}};\n",
|
| 170 |
+
" var render_items = [{\"docid\":\"213b43a3-1f08-4198-a068-6908f1b8f385\",\"roots\":{\"1abf19e8-c829-4091-925a-9114dd4220aa\":\"ce3ddf3d-c57f-400b-acb4-f4d3c8688f2e\"},\"root_ids\":[\"1abf19e8-c829-4091-925a-9114dd4220aa\"]}];\n",
|
| 171 |
" var docs = Object.values(docs_json)\n",
|
| 172 |
" if (!docs) {\n",
|
| 173 |
" return\n",
|
|
|
|
| 231 |
},
|
| 232 |
"metadata": {
|
| 233 |
"application/vnd.holoviews_exec.v0+json": {
|
| 234 |
+
"id": "1abf19e8-c829-4091-925a-9114dd4220aa"
|
| 235 |
}
|
| 236 |
},
|
| 237 |
"output_type": "display_data"
|
|
|
|
| 255 |
},
|
| 256 |
{
|
| 257 |
"cell_type": "code",
|
| 258 |
+
"execution_count": 13,
|
| 259 |
"metadata": {},
|
| 260 |
"outputs": [],
|
| 261 |
"source": [
|
|
|
|
| 279 |
},
|
| 280 |
{
|
| 281 |
"cell_type": "code",
|
| 282 |
+
"execution_count": 14,
|
| 283 |
"metadata": {},
|
| 284 |
"outputs": [],
|
| 285 |
"source": [
|
|
|
|
| 293 |
},
|
| 294 |
{
|
| 295 |
"cell_type": "code",
|
| 296 |
+
"execution_count": 15,
|
| 297 |
"metadata": {},
|
| 298 |
"outputs": [],
|
| 299 |
"source": [
|
|
|
|
| 307 |
" if file is None:\n",
|
| 308 |
" return \"No file selected\"\n",
|
| 309 |
" df = pd.read_csv(io.BytesIO(file))\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 310 |
" \n",
|
| 311 |
+
" visualizations = utils.Visualizations(df, pn)\n",
|
| 312 |
+
" high_level_widget = visualizations.high_level_visualization()\n",
|
| 313 |
+
" shape_widget = visualizations.data_shape_visualization()\n",
|
| 314 |
+
" nature_widget = visualizations.nature_visualization()\n",
|
| 315 |
+
" distribution_widget = visualizations.distribution_visualization()\n",
|
| 316 |
+
" \n",
|
| 317 |
+
" return pn.Column(\n",
|
| 318 |
+
" high_level_widget,\n",
|
| 319 |
+
" pn.Row(shape_widget,\n",
|
| 320 |
+
" nature_widget,\n",
|
| 321 |
+
" distribution_widget)\n",
|
| 322 |
" )\n",
|
|
|
|
| 323 |
" \n",
|
| 324 |
"\n",
|
| 325 |
"bound_data = pn.bind(get_data, switch=switch, url=url, file=file)\n",
|
|
|
|
| 333 |
},
|
| 334 |
{
|
| 335 |
"cell_type": "code",
|
| 336 |
+
"execution_count": 16,
|
| 337 |
"metadata": {},
|
| 338 |
"outputs": [],
|
| 339 |
"source": [
|
|
|
|
| 342 |
},
|
| 343 |
{
|
| 344 |
"cell_type": "code",
|
| 345 |
+
"execution_count": 17,
|
| 346 |
"metadata": {},
|
| 347 |
"outputs": [],
|
| 348 |
"source": [
|
|
|
|
| 357 |
},
|
| 358 |
{
|
| 359 |
"cell_type": "code",
|
| 360 |
+
"execution_count": 18,
|
| 361 |
"metadata": {},
|
| 362 |
"outputs": [],
|
| 363 |
"source": [
|
app.py
CHANGED
|
@@ -9,6 +9,7 @@ import hvplot.pandas
|
|
| 9 |
import pandas as pd
|
| 10 |
import numpy as np
|
| 11 |
import io
|
|
|
|
| 12 |
|
| 13 |
|
| 14 |
|
|
@@ -61,23 +62,19 @@ def get_data(switch: pn.widgets.Switch, url: pn.widgets.TextAreaInput, file: pn.
|
|
| 61 |
if file is None:
|
| 62 |
return "No file selected"
|
| 63 |
df = pd.read_csv(io.BytesIO(file))
|
| 64 |
-
|
| 65 |
-
widget = pn.Column(
|
| 66 |
-
pn.pane.Markdown(
|
| 67 |
-
"""
|
| 68 |
-
## Data Preview
|
| 69 |
-
|
| 70 |
-
Here is a preview of the data.
|
| 71 |
-
"""
|
| 72 |
-
),
|
| 73 |
-
pn.pane.Markdown(f"### Data Shape: {df.shape}"),
|
| 74 |
-
pn.pane.Markdown(f"### Data Head"),
|
| 75 |
-
pn.pane.DataFrame(df.head(5)),
|
| 76 |
-
pn.pane.Markdown(f"### Describe"),
|
| 77 |
-
pn.pane.DataFrame(df.describe()),
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
)
|
| 80 |
-
return widget
|
| 81 |
|
| 82 |
|
| 83 |
bound_data = pn.bind(get_data, switch=switch, url=url, file=file)
|
|
|
|
| 9 |
import pandas as pd
|
| 10 |
import numpy as np
|
| 11 |
import io
|
| 12 |
+
import helpers.utils as utils
|
| 13 |
|
| 14 |
|
| 15 |
|
|
|
|
| 62 |
if file is None:
|
| 63 |
return "No file selected"
|
| 64 |
df = pd.read_csv(io.BytesIO(file))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
+
visualizations = utils.Visualizations(df, pn)
|
| 67 |
+
high_level_widget = visualizations.high_level_visualization()
|
| 68 |
+
shape_widget = visualizations.data_shape_visualization()
|
| 69 |
+
nature_widget = visualizations.nature_visualization()
|
| 70 |
+
distribution_widget = visualizations.distribution_visualization()
|
| 71 |
+
|
| 72 |
+
return pn.Column(
|
| 73 |
+
high_level_widget,
|
| 74 |
+
pn.Row(shape_widget,
|
| 75 |
+
nature_widget,
|
| 76 |
+
distribution_widget)
|
| 77 |
)
|
|
|
|
| 78 |
|
| 79 |
|
| 80 |
bound_data = pn.bind(get_data, switch=switch, url=url, file=file)
|
helpers/__init__.py
ADDED
|
File without changes
|
helpers/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (198 Bytes). View file
|
|
|
helpers/__pycache__/utils.cpython-311.pyc
ADDED
|
Binary file (5.98 kB). View file
|
|
|
helpers/utils.py
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
from math import e
|
| 3 |
+
import panel as pn
|
| 4 |
+
import pandas as pd
|
| 5 |
+
import hvplot.pandas
|
| 6 |
+
|
| 7 |
+
# A class to process the dataframe and create visualizations according to the shape, nature, and distribution of the data.
|
| 8 |
+
class Visualizations:
|
| 9 |
+
def __init__(self, df, pn: pn):
|
| 10 |
+
self.df = df
|
| 11 |
+
self.pn = pn
|
| 12 |
+
|
| 13 |
+
def high_level_visualization(self):
|
| 14 |
+
# Create a high-level visualization of the dataframe
|
| 15 |
+
# Check the number of rows and columns in the dataframe
|
| 16 |
+
rows, columns = self.df.shape
|
| 17 |
+
|
| 18 |
+
if columns > 7:
|
| 19 |
+
widget = self.pn.Column(
|
| 20 |
+
self.pn.pane.Markdown(
|
| 21 |
+
"""
|
| 22 |
+
# Data Preview
|
| 23 |
+
|
| 24 |
+
### Here is a preview of the dataset.
|
| 25 |
+
"""
|
| 26 |
+
),
|
| 27 |
+
self.pn.Column(
|
| 28 |
+
self.pn.Column(
|
| 29 |
+
self.pn.pane.Markdown("## Head"),
|
| 30 |
+
self.pn.pane.DataFrame(self.df.head(5)),
|
| 31 |
+
),
|
| 32 |
+
self.pn.Column(
|
| 33 |
+
self.pn.pane.Markdown("## Describe"),
|
| 34 |
+
self.pn.pane.DataFrame(self.df.describe(),)
|
| 35 |
+
),
|
| 36 |
+
),
|
| 37 |
+
|
| 38 |
+
)
|
| 39 |
+
return widget
|
| 40 |
+
else:
|
| 41 |
+
widget = self.pn.Column(
|
| 42 |
+
self.pn.pane.Markdown(
|
| 43 |
+
"""
|
| 44 |
+
# Data Preview
|
| 45 |
+
|
| 46 |
+
### Here is a preview of the dataset.
|
| 47 |
+
"""
|
| 48 |
+
),
|
| 49 |
+
self.pn.Row(
|
| 50 |
+
self.pn.Column(
|
| 51 |
+
self.pn.pane.Markdown("## Head"),
|
| 52 |
+
self.pn.pane.DataFrame(self.df.head(5)),
|
| 53 |
+
),
|
| 54 |
+
self.pn.Column(
|
| 55 |
+
self.pn.pane.Markdown("## Describe"),
|
| 56 |
+
self.pn.pane.DataFrame(self.df.describe(),)
|
| 57 |
+
),
|
| 58 |
+
),
|
| 59 |
+
|
| 60 |
+
)
|
| 61 |
+
return widget
|
| 62 |
+
|
| 63 |
+
def data_shape_visualization(self):
|
| 64 |
+
# Create a visualization of the shape of the dataframe
|
| 65 |
+
widget = self.pn.Column(
|
| 66 |
+
self.pn.pane.Markdown(
|
| 67 |
+
"""
|
| 68 |
+
# Data Shape
|
| 69 |
+
|
| 70 |
+
### Here is the shape of the dataset.
|
| 71 |
+
"""
|
| 72 |
+
),
|
| 73 |
+
self.pn.Column(
|
| 74 |
+
self.pn.Column(
|
| 75 |
+
self.pn.pane.Markdown("## Shape"),
|
| 76 |
+
self.pn.pane.DataFrame(pd.DataFrame({'Rows': [self.df.shape[0]], 'Columns': [self.df.shape[1]]}),
|
| 77 |
+
)),
|
| 78 |
+
),
|
| 79 |
+
)
|
| 80 |
+
return widget
|
| 81 |
+
|
| 82 |
+
def nature_visualization(self):
|
| 83 |
+
# Create a visualization of the nature of the dataframe
|
| 84 |
+
widget = self.pn.Column(
|
| 85 |
+
self.pn.pane.Markdown(
|
| 86 |
+
"""
|
| 87 |
+
# Data Nature
|
| 88 |
+
|
| 89 |
+
### Here is the nature of the dataset.
|
| 90 |
+
"""
|
| 91 |
+
),
|
| 92 |
+
self.pn.Row(
|
| 93 |
+
self.pn.Column(
|
| 94 |
+
self.pn.pane.Markdown("## Data Types"),
|
| 95 |
+
self.pn.pane.DataFrame(self.df.dtypes.to_frame(),)
|
| 96 |
+
),
|
| 97 |
+
self.pn.Column(
|
| 98 |
+
self.pn.pane.Markdown("## Null Values"),
|
| 99 |
+
self.pn.pane.DataFrame(self.df.isnull().sum().to_frame(),)
|
| 100 |
+
),
|
| 101 |
+
),
|
| 102 |
+
)
|
| 103 |
+
return widget
|
| 104 |
+
|
| 105 |
+
def distribution_visualization(self):
|
| 106 |
+
# Create a visualization of the distribution of the dataframe
|
| 107 |
+
widget = self.pn.Column(
|
| 108 |
+
self.pn.pane.Markdown(
|
| 109 |
+
"""
|
| 110 |
+
# Data Distribution
|
| 111 |
+
|
| 112 |
+
### Here is the distribution of the dataset.
|
| 113 |
+
"""
|
| 114 |
+
),
|
| 115 |
+
self.pn.Column(
|
| 116 |
+
self.pn.Column(
|
| 117 |
+
self.pn.pane.Markdown("## Distribution"),
|
| 118 |
+
self.df.hvplot.density()
|
| 119 |
+
),
|
| 120 |
+
),
|
| 121 |
+
)
|
| 122 |
+
return widget
|
requirements.txt
CHANGED
|
@@ -4,3 +4,4 @@ transformers
|
|
| 4 |
numpy
|
| 5 |
aiohttp
|
| 6 |
hvplot
|
|
|
|
|
|
| 4 |
numpy
|
| 5 |
aiohttp
|
| 6 |
hvplot
|
| 7 |
+
scipy
|