{ "info": { "author": "Marc Wouts", "author_email": "marc.wouts@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Framework :: Jupyter", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "# Pandas DataFrames and Series as Interactive Tables in Jupyter\n\n[![Pypi](https://img.shields.io/pypi/v/itables.svg)](https://pypi.python.org/pypi/itables)\n[![Build Status](https://travis-ci.com/mwouts/itables.svg?branch=master)](https://travis-ci.com/mwouts/itables)\n[![codecov.io](https://codecov.io/github/mwouts/itables/coverage.svg?branch=master)](https://codecov.io/github/mwouts/itables?branch=master)\n[![Binder](https://img.shields.io/badge/Binder-Notebook-blue.svg)](https://mybinder.org/v2/gh/mwouts/itables/master?filepath=README.md)\n\n\nTurn pandas DataFrames and Series into interactive [datatables](https://datatables.net) in both your notebooks and their HTML representation with a single additional import:\n\n```python\nimport itables.interactive\nimport world_bank_data as wb\n\ndf = wb.get_countries()\ndf\n```\n\nYou don't see any table above? Please either open the [HTML export](https://mwouts.github.io/itables/) of this notebook, or run this README on [![Binder](https://img.shields.io/badge/Binder-blue.svg)](https://mybinder.org/v2/gh/mwouts/itables/master?filepath=README.md)!\n\n\n# Quick start\n\nInstall the package with\n\n```\npip install itables\n```\n\nActivate the interactive mode for all series and dataframes with\n\n```python\nimport itables.interactive\n```\n\nDisplay just one series or dataframe as an interactive table with the `show` function.\n\n```python\nfrom itables import show\n\nx = wb.get_series(\"SP.POP.TOTL\", mrv=1, simplify_index=True)\nshow(x)\n```\n\n# Advanced usage\n\n## Pagination\n\n### How many rows per page\n\nSelect [how many entries](https://datatables.net/examples/advanced_init/length_menu.html) should appear at once in the table with the `lengthMenu` argument of the `show` function, or by changing `itables.options.default`:\n\n```python\nimport itables.options as opt\n\nopt.lengthMenu = [2, 5, 10, 20, 50, 100, 200, 500]\ndf\n```\n\n### Show the table in full\n\nShow the table in full with the [`paging` argument](https://datatables.net/reference/option/paging), either in the `show` method, or in the options:\n\n```python\nshow(df.head(), paging=False)\n```\n\n### Scroll\n\nIf you prefer to replace the pagination with a [vertical scroll](https://datatables.net/examples/basic_init/scroll_y.html), use for instance\n\n```python\nshow(df, scrollY=\"200px\", scrollCollapse=True, paging=False)\n```\n\n## Table and cell style\n\nSelect how your table should look like with the `classes` argument of the `show` function, or by changing `itables.options.classes`. For the list of possible values, see [datatables' default style](https://datatables.net/manual/styling/classes) and [the style examples](https://datatables.net/examples/styling/).\n\n```python\nopt.classes = [\"display\", \"nowrap\"]\ndf\n```\n\n```python\nopt.classes = [\"display\", \"cell-border\"]\ndf\n```\n\n## Float precision\n\nFloats are rounded using `pd.options.display.float_format`. Please change that format according to your preference.\n\n```python\nimport math\nimport pandas as pd\n\nwith pd.option_context(\"display.float_format\", \"{:,.2f}\".format):\n show(pd.Series([i * math.pi for i in range(1, 6)]))\n```\n\nYou may also choose to convert floating numbers to strings:\n\n```python\nwith pd.option_context(\"display.float_format\", \"${:,.2f}\".format):\n show(pd.Series([i * math.pi for i in range(1, 6)]))\n```\n\n## Advanced cell formatting\n\nDatatables allows to set the cell or row style depending on the cell content, with either the [createdRow](https://datatables.net/reference/option/createdRow) or [createdCell](https://datatables.net/reference/option/columns.createdCell) callback. For instance, if we want the cells with negative numbers to be colored in red, we can use the `columnDefs.createdCell` argument as follows:\n\n```python\nshow(\n pd.DataFrame([[-1, 2, -3, 4, -5], [6, -7, 8, -9, 10]], columns=list(\"abcde\")),\n columnDefs=[\n {\n \"targets\": \"_all\",\n \"createdCell\": \"\"\"function (td, cellData, rowData, row, col) {\n if ( cellData < 0 ) {\n $(td).css('color', 'red')\n }\n }\"\"\",\n }\n ],\n)\n```\n\n## Column width\n\nFIXME: This does not appear to be working...\n\n```python\nshow(df, columnsDefs=[{\"width\": \"200px\", \"target\": 3}])\n```\n\nBut in some cases - a table with many column like the one below, we can use the `width` parameter...\n\n```python\nshow(x.to_frame().T, columnDefs=[{\"width\": \"80px\", \"targets\": \"_all\"}])\n```\n\n## HTML in cells\n\n```python\nimport pandas as pd\n\nshow(\n pd.Series(\n [\n \"bold\",\n \"italic\",\n 'link',\n ],\n name=\"HTML\",\n ),\n paging=False,\n)\n```\n\n## Select rows\n\nNot currently implemented. May be made available at a later stage using the [select](https://datatables.net/extensions/select/) extension for datatables.\n\n\n## Copy, CSV, PDF and Excel buttons\n\nNot currently implemented. May be made available at a later stage thanks to the [buttons](https://datatables.net/extensions/buttons/) extension for datatable.\n\n\n## Large table support\n\n`itables` will not display dataframes that are larger than `maxBytes`, which is equal to 1MB by default. Truncate the dataframe with `df.head()`, or set the `maxBytes` parameter or option to an other value to display the dataframe. Or deactivate the limit with `maxBytes=0`.\n\nNote that datatables support [server-side processing](https://datatables.net/examples/data_sources/server_side). At a later stage we may implement support for larger tables using this feature.\n\n```python\ndf = wb.get_indicators()\ndf.values.nbytes\n```\n\n```python\nopt.maxBytes = 1000000\ndf\n```\n\n# References\n\n## DataTables\n\n- DataTables is a plug-in for the jQuery Javascript library. It has a great [documentation](https://datatables.net/manual/), and a large set of [examples](https://datatables.net/examples/index).\n- The R package [DT](https://rstudio.github.io/DT/) uses [datatables.net](https://datatables.net/) as the underlying library for both R notebooks and Shiny applications. In addition to the standard functionalities of the library (display, sort, filtering and row selection), RStudio seems to have implemented cell edition.\n- Marek Cermak has an interesting [tutorial](https://medium.com/@marekermk/guide-to-interactive-pandas-dataframe-representation-485acae02946) on how to use datatables within Jupyter. He also published [jupyter-datatables](https://github.com/CermakM/jupyter-datatables), with a focus on numerical data and distribution plots.\n\n## Alternatives\n\nITables is not a Jupyter widget, which means that it does not allows you to **edit** the content of the dataframe.\nIf you are looking for Jupyter widgets, have a look at\n- [QGrid](https://github.com/quantopian/qgrid) by Quantopian\n- [IPyaggrid](https://dgothrek.gitlab.io/ipyaggrid/) by Louis Raison and Olivier Borderies\n- [IPySheet](https://github.com/QuantStack/ipysheet) by QuantStack.\n\nIf you are looking for a table component that will fit in Dash applications, see [datatable by Dash](https://github.com/plotly/dash-table/).\n\n## Contributing\n\nI think it would be very helpful to have an identical table component for both Jupyter and [Dash](http://dash.plot.ly/). Please [let us know](https://community.plot.ly/t/why-does-dash-have-its-own-datatable-library/) if you are interested in drafting a new table component based on an existing Javascript library for Dash.\n\nAlso, if you happen to prefer another Javascript table library (say, [ag-grid](https://www.ag-grid.com/)), and you would like to see it supported in `itables`, please open either an issue or a PR, and let us know what is the minimal code to display a table in Jupyter using your library.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/mwouts/itables", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "itables", "package_url": "https://pypi.org/project/itables/", "platform": "", "project_url": "https://pypi.org/project/itables/", "project_urls": { "Homepage": "https://github.com/mwouts/itables" }, "release_url": "https://pypi.org/project/itables/0.1.0/", "requires_dist": null, "requires_python": "", "summary": "Interactive Tables in Jupyter", "version": "0.1.0" }, "last_serial": 5175007, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "765e8945b23c7dd3df1777bc18e0b4f2", "sha256": "a5b958698ea292eeeb9d8d432afe326e606056d37ec97e21ad3630e8ed800037" }, "downloads": -1, "filename": "itables-0.1.0.tar.gz", "has_sig": false, "md5_digest": "765e8945b23c7dd3df1777bc18e0b4f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9035, "upload_time": "2019-04-22T23:49:01", "url": "https://files.pythonhosted.org/packages/13/ec/d8e6ca70930d93e97153cbb430c2b5431127dbf50f458a5685b28897a7bc/itables-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "765e8945b23c7dd3df1777bc18e0b4f2", "sha256": "a5b958698ea292eeeb9d8d432afe326e606056d37ec97e21ad3630e8ed800037" }, "downloads": -1, "filename": "itables-0.1.0.tar.gz", "has_sig": false, "md5_digest": "765e8945b23c7dd3df1777bc18e0b4f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9035, "upload_time": "2019-04-22T23:49:01", "url": "https://files.pythonhosted.org/packages/13/ec/d8e6ca70930d93e97153cbb430c2b5431127dbf50f458a5685b28897a7bc/itables-0.1.0.tar.gz" } ] }