{ "cells": [ { "cell_type": "markdown", "metadata": { "toc": true }, "source": [ "<h1>Table of Contents<span class=\"tocSkip\"></span></h1>\n", "<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#New-in-v0.4.0\" data-toc-modified-id=\"New-in-v0.4.0-1\"><span class=\"toc-item-num\">1 </span>New in v0.4.0</a></span></li><li><span><a href=\"#Changes\" data-toc-modified-id=\"Changes-2\"><span class=\"toc-item-num\">2 </span>Changes</a></span></li><li><span><a href=\"#Setup\" data-toc-modified-id=\"Setup-3\"><span class=\"toc-item-num\">3 </span>Setup</a></span></li><li><span><a href=\"#Data\" data-toc-modified-id=\"Data-4\"><span class=\"toc-item-num\">4 </span>Data</a></span></li><li><span><a href=\"#Representation\" data-toc-modified-id=\"Representation-5\"><span class=\"toc-item-num\">5 </span>Representation</a></span></li><li><span><a href=\"#Disable-DataTables\" data-toc-modified-id=\"Disable-DataTables-6\"><span class=\"toc-item-num\">6 </span>Disable DataTables</a></span></li><li><span><a href=\"#Enable-DataTables-again\" data-toc-modified-id=\"Enable-DataTables-again-7\"><span class=\"toc-item-num\">7 </span>Enable DataTables again</a></span></li></ul></div>" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# [Preview] Jupyter DataTables v0.4.0\n", "\n", "<br>\n", " \n", "## New in v0.4.0\n", "\n", "- [x] Interactvie chart **Toolbar**\n", "- [x] Graph type selection via the toolbar settings\n", "- [x] autoloading\n", "- [x] disable/enable DataTables\n", "\n", "## Changes\n", "\n", "- [x] Refactorings:\n", " - `dTypePlotMap` -> `chartMap`" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setup" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2019-12-11T12:02:11.729974Z", "start_time": "2019-12-11T12:02:11.669733Z" } }, "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2019-12-11T12:02:12.146034Z", "start_time": "2019-12-11T12:02:11.733322Z" } }, "outputs": [], "source": [ "import sys\n", "import string\n", "\n", "import numpy as np\n", "import pandas as pd" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2019-12-11T12:02:12.164947Z", "start_time": "2019-12-11T12:02:12.148074Z" } }, "outputs": [], "source": [ "sys.path.insert(0, '/home/macermak/code/jupyter-datatables/')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2019-12-11T12:02:12.192088Z", "start_time": "2019-12-11T12:02:12.167236Z" }, "require": [ "notebook/js/codecell" ] }, "outputs": [], "source": [ "from jupyter_datatables import init_datatables_mode" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2019-12-11T12:02:12.240829Z", "start_time": "2019-12-11T12:02:12.195283Z" } }, "outputs": [], "source": [ "init_datatables_mode()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Data" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2019-12-11T12:02:20.039448Z", "start_time": "2019-12-11T12:02:19.910123Z" } }, "outputs": [], "source": [ "df = pd.DataFrame(np.random.randn(50, 5), columns=list(string.ascii_uppercase[:5]))\n", "df_long = pd.DataFrame(np.random.randn(int(1e5), 5), columns=list(string.ascii_uppercase[:5]))\n", "df_wide = pd.DataFrame(np.random.randn(50, 20), columns=list(string.ascii_uppercase[:20]))\n", "\n", "labels = [\"{0} - {1}\".format(i, i + 9) for i in range(0, 100, 10)]\n", "df_categorical = pd.DataFrame({'value': np.random.randint(0, 100, 20)})\n", "df_categorical['group'] = pd.cut(df_categorical.value, range(0, 105, 10), right=False, labels=labels)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2019-12-11T12:02:20.073748Z", "start_time": "2019-12-11T12:02:20.042409Z" } }, "outputs": [], "source": [ "dft = pd.DataFrame({'A': np.random.rand(5),\n", " 'B': [1, 1, 3, 2, 1],\n", " 'C': 'This is a very long sentence that should automatically be trimmed',\n", " 'D': [pd.Timestamp('20010101'), pd.Timestamp('20010102'), pd.Timestamp('20010103'), pd.Timestamp('20010104'), pd.Timestamp('20010105')],\n", " 'E': pd.Series([1.0] * 5).astype('float32'),\n", " 'F': [False, True, False, False, True],\n", " })\n", "\n", "dft.D = dft.D.apply(pd.to_datetime)\n", "dft.set_index('D', inplace=True)\n", "\n", "del dft.index.name" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Representation" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2019-12-11T12:02:22.461391Z", "start_time": "2019-12-11T12:02:22.309395Z" }, "require": [ "base/js/events", "datatables.net", "d3", "chartjs", "dt-config", "dt-components", "dt-graph-objects", "dt-toolbar", "dt-tooltips", "jupyter-datatables" ], "scrolled": false, "slideshow": { "slide_type": "slide" } }, "outputs": [], "source": [ "dft" ] }, { "cell_type": "markdown", "metadata": { "ExecuteTime": { "end_time": "2019-12-11T12:02:35.211750Z", "start_time": "2019-12-11T12:02:35.182880Z" } }, "source": [ "## Disable DataTables" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2019-12-11T12:02:53.061400Z", "start_time": "2019-12-11T12:02:52.994215Z" } }, "outputs": [], "source": [ "from jupyter_datatables import disable_datatables_mode\n", "\n", "disable_datatables_mode()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The representation is now the standard pandas DataFrame" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2019-12-11T12:04:07.600351Z", "start_time": "2019-12-11T12:04:06.980227Z" }, "require": [ "base/js/events", "datatables.net", "d3", "chartjs", "dt-config", "dt-components", "dt-graph-objects", "dt-toolbar", "dt-tooltips", "jupyter-datatables" ] }, "outputs": [], "source": [ "df_long" ] }, { "cell_type": "markdown", "metadata": { "ExecuteTime": { "end_time": "2019-12-11T12:03:12.792260Z", "start_time": "2019-12-11T12:03:12.733924Z" } }, "source": [ "## Enable DataTables again" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2019-12-11T12:03:46.215448Z", "start_time": "2019-12-11T12:03:46.167570Z" } }, "outputs": [], "source": [ "from jupyter_datatables import enable_datatables_mode\n", "\n", "enable_datatables_mode()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2019-12-11T12:03:59.089418Z", "start_time": "2019-12-11T12:03:58.060112Z" }, "require": [ "base/js/events", "datatables.net", "d3", "chartjs", "dt-config", "dt-components", "dt-graph-objects", "dt-toolbar", "dt-tooltips", "jupyter-datatables" ] }, "outputs": [], "source": [ "df_long" ] } ], "metadata": { "celltoolbar": "Slideshow", "finalized": { "timestamp": 1576065900631, "trusted": true }, "hide_input": false, "kernelspec": { "display_name": "jupyter-datatables", "language": "python", "name": "jupyter-datatables" }, "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.8" }, "require": { "paths": { "buttons.colvis": "https://cdn.datatables.net/buttons/1.5.6/js/buttons.colVis.min", "buttons.flash": "https://cdn.datatables.net/buttons/1.5.6/js/buttons.flash.min", "buttons.html5": "https://cdn.datatables.net/buttons/1.5.6/js/buttons.html5.min", "buttons.print": "https://cdn.datatables.net/buttons/1.5.6/js/buttons.print.min", "chartjs": "https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart", "d3": "https://d3js.org/d3.v5.min", "d3-array": "https://d3js.org/d3-array.v2.min", "datatables.net": "https://cdn.datatables.net/1.10.18/js/jquery.dataTables", "datatables.net-buttons": "https://cdn.datatables.net/buttons/1.5.6/js/dataTables.buttons.min", "datatables.responsive": "https://cdn.datatables.net/responsive/2.2.2/js/dataTables.responsive.min", "datatables.scroller": "https://cdn.datatables.net/scroller/2.0.0/js/dataTables.scroller.min", "datatables.select": "https://cdn.datatables.net/select/1.3.0/js/dataTables.select.min", "jszip": "https://cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min", "moment": "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.0/moment", "pdfmake": "https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min", "vfsfonts": "https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts" }, "shim": { "buttons.colvis": { "deps": [ "jszip", "datatables.net-buttons" ] }, "buttons.flash": { "deps": [ "jszip", "datatables.net-buttons" ] }, "buttons.html5": { "deps": [ "jszip", "datatables.net-buttons" ] }, "buttons.print": { "deps": [ "jszip", "datatables.net-buttons" ] }, "chartjs": { "deps": [ "moment" ] }, "datatables.net": { "exports": "$.fn.dataTable" }, "datatables.net-buttons": { "deps": [ "datatables.net" ] }, "pdfmake": { "deps": [ "datatables.net" ] }, "vfsfonts": { "deps": [ "datatables.net" ] } } }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": true, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": true, "toc_position": {}, "toc_section_display": true, "toc_window_display": false }, "varInspector": { "cols": { "lenName": 16, "lenType": 16, "lenVar": 40 }, "kernels_config": { "python": { "delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())" }, "r": { "delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) " } }, "types_to_exclude": [ "module", "function", "builtin_function_or_method", "instance", "_Feature" ], "window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }