{"id":13398156,"url":"https://github.com/quantopian/qgrid","last_synced_at":"2025-04-10T02:13:15.947Z","repository":{"id":21308185,"uuid":"24624545","full_name":"quantopian/qgrid","owner":"quantopian","description":"An interactive grid for sorting, filtering, and editing DataFrames in Jupyter notebooks","archived":false,"fork":false,"pushed_at":"2024-01-12T07:28:07.000Z","size":50522,"stargazers_count":3068,"open_issues_count":182,"forks_count":425,"subscribers_count":86,"default_branch":"master","last_synced_at":"2025-04-10T02:13:07.681Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quantopian.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-09-30T04:33:20.000Z","updated_at":"2025-03-24T18:03:13.000Z","dependencies_parsed_at":"2023-01-14T00:30:20.015Z","dependency_job_id":"a383eff0-c0e5-4ff2-98ac-df7f0d2a6fc7","html_url":"https://github.com/quantopian/qgrid","commit_stats":{"total_commits":348,"total_committers":29,"mean_commits":12.0,"dds":0.3477011494252874,"last_synced_commit":"877b420d3bd83297bbcc97202b914001a85afff2"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantopian%2Fqgrid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantopian%2Fqgrid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantopian%2Fqgrid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantopian%2Fqgrid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quantopian","download_url":"https://codeload.github.com/quantopian/qgrid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248142903,"owners_count":21054671,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T19:00:18.629Z","updated_at":"2025-04-10T02:13:15.925Z","avatar_url":"https://github.com/quantopian.png","language":"Python","readme":".. image:: https://media.quantopian.com/logos/open_source/qgrid-logo-03.png\n    :target: https://qgrid.readthedocs.io\n    :width: 190px\n    :align: center\n    :alt: qgrid\n\n=====\nqgrid\n=====\nQgrid is a Jupyter notebook widget which uses `SlickGrid \u003chttps://github.com/mleibman/SlickGrid\u003e`_ to render pandas\nDataFrames within a Jupyter notebook. This allows you to explore your DataFrames with intuitive scrolling, sorting, and\nfiltering controls, as well as edit your DataFrames by double clicking cells.\n\nQgrid was developed for use in `Quantopian's hosted research environment\n\u003chttps://www.quantopian.com/posts/qgrid-now-available-in-research-an-interactive-grid-for-sorting-and-filtering-dataframes?utm_source=github\u0026utm_medium=web\u0026utm_campaign=qgrid-repo\u003e`_\nand is available for use in that environment as of June 2018.\nQuantopian also offers a `fully managed service for professionals \u003chttps://factset.quantopian.com\u003e`_\nthat includes Qgrid, Zipline, Alphalens, Pyfolio, FactSet data, and more.\n\nAnnouncements: Qgrid Webinar\n----------------------------\nQgrid author Tim Shawver recently did a live webinar about Qgrid, and the recording of the webinar is `now available on YouTube \u003chttps://www.youtube.com/watch?v=AsJJpgwIX0Q\u003e`_.\n\nThis talk will be interesting both for people that are new to Qgrid, as well as longtime fans that are interested in learning more about the project.\n\nDemo\n----\nClick the badge below to try out the latest beta of qgrid in Quantopian's hosted research environment. If you're already signed into Quantopian you'll be brought directly to the demo notebook. Otherwise you'll be prompted to register (it's free):\n\n.. image:: https://img.shields.io/badge/launch-quantopian-red.svg?colorB=d33015\n    :target: https://www.quantopian.com/clone_notebook?id=5b2baee1b3d6870048620188\u0026utm_source=github\u0026utm_medium=web\u0026utm_campaign=qgrid-repo\n|\nClick the badge below to try out qgrid using binder:\n\n.. image:: https://beta.mybinder.org/badge.svg\n    :target: https://mybinder.org/v2/gh/quantopian/qgrid-notebooks/master?filepath=index.ipynb\n|\nClick the following badge to try out qgrid in Jupyterlab, also using binder:\n\n.. image:: https://mybinder.org/badge.svg\n    :target: https://mybinder.org/v2/gh/quantopian/qgrid-notebooks/master?urlpath=lab\n|\n*For both binder links, you'll see a brief loading screen while a server is being created for you in the cloud.  This shouldn't take more than a minute, and usually completes in under 10 seconds.*\n\n*The binder demos generally will be using the most recent stable release of qgrid, so features that were added in a recent beta version may not be available in those demos.*\n\nFor people who would rather not go to another page to try out qgrid for real, here's the tldr; version:\n\n        .. figure:: docs/images/filtering_demo.gif\n         :align: left\n         :target: docs/images/filtering_demo.gif\n         :width: 200px\n\n          A brief demo showing filtering, editing, and the `get_changed_df()` method\n\nAPI Documentation\n-----------------\nAPI documentation is hosted on `readthedocs \u003chttp://qgrid.readthedocs.io/en/latest/\u003e`_.\n\nInstallation\n------------\n\nInstalling with pip::\n\n  pip install qgrid\n  jupyter nbextension enable --py --sys-prefix qgrid\n\n  # only required if you have not enabled the ipywidgets nbextension yet\n  jupyter nbextension enable --py --sys-prefix widgetsnbextension\n\nInstalling with conda::\n\n  # only required if you have not added conda-forge to your channels yet\n  conda config --add channels conda-forge\n\n  conda install qgrid\n\nJupyterlab Installation\n-----------------------\n\nFirst, go through the normal installation steps above as you normally would when using qgrid in the notebook.\nIf you haven't already install jupyterlab and enabled ipywidgets, do that first with the following lines::\n\n  pip install jupyterlab\n  jupyter labextension install @jupyter-widgets/jupyterlab-manager\n\nInstall the qgrid-jupyterlab extension and enable::\n\n  jupyter labextension install qgrid2\n\nAt this point if you run jupyter lab normally with the 'jupyter lab' command, you should be\nable to use qgrid in notebooks as you normally would.\n\n*Please Note: Jupyterlab support has been tested with jupyterlab 0.30.5 and jupyterlab-manager 0.31.3, so if you're\nhaving trouble, try installing those versions. Feel free to file an issue if you find that qgrid isn't working\nwith a newer version of either dependency.*\n\nWhat's New\n----------\n**Column-specific options (as of 1.1.0)**:\nThanks to a significant `PR from the community \u003chttps://github.com/quantopian/qgrid/pull/191\u003e`_, Qgrid users now have the ability to set a number of options on a per column basis.  This allows you to do things like explicitly specify which column should be sortable, editable, etc.  For example, if you wanted to prevent editing on all columns except for a column named `'A'`, you could do the following::\n\n    col_opts = { 'editable': False }\n    col_defs = { 'A': { 'editable': True } }\n    qgrid.show_grid(df, column_options=col_opts, column_definitions=col_defs)\n\nSee the updated `show_grid \u003chttps://qgrid.readthedocs.io/en/v1.1.0/#qgrid.show_grid\u003e`_ documentation for more information.\n\n**Disable editing on a per-row basis (as of 1.1.0)**:\nThis feature can be thought of as the first row-specific option that qgrid supports.  In particular it allows a user to specify, using python code, whether or not a particular row should be editable. For example, to make it so only rows in the grid where the `'status'` column is set to `'active'` are editable, you might use the following code::\n\n    def can_edit_row(row):\n        return row['status'] == 'active'\n\n    qgrid.show_grid(df, row_edit_callback=can_edit_row)\n\n**New API methods for dynamically updating an existing qgrid widget (as of 1.1.0)**:\nAdds the following new methods, which can be used to update the state of an existing Qgrid widget without having to call `show_grid` to completely rebuild the widget:\n\n    - `edit_cell \u003chttps://qgrid.readthedocs.io/en/latest/#qgrid.QgridWidget.edit_cell\u003e`_\n    - `change_selection \u003chttps://qgrid.readthedocs.io/en/latest/#qgrid.QgridWidget.change_selection\u003e`_\n    - `toggle_editable \u003chttps://qgrid.readthedocs.io/en/latest/#qgrid.QgridWidget.toggle_editable\u003e`_\n    - `change_grid_option \u003chttps://qgrid.readthedocs.io/en/latest/#qgrid.QgridWidget.change_grid_option\u003e`_ (experimental)\n\n**Improved MultiIndex Support (as of 1.0.6-beta.6)**:\nQgrid now displays multi-indexed DataFrames with some of the index cells merged for readability, as is normally done when viewing DataFrames as a static html table.  The following image shows qgrid displaying a multi-indexed DataFrame that was returned from Quantopian's `Pipeline API \u003chttps://www.quantopian.com/tutorials/pipeline?utm_source=github\u0026utm_medium=web\u0026utm_campaign=qgrid-repo\u003e`_:\n\n.. figure:: https://s3.amazonaws.com/quantopian-forums/pipeline_with_qgrid.png\n         :align: left\n         :target: https://s3.amazonaws.com/quantopian-forums/pipeline_with_qgrid.png\n         :width: 100px\n\nDependencies\n------------\n\nQgrid runs on `Python 2 or 3 \u003chttps://www.python.org/downloads/\u003e`_.  You'll also need\n`pip \u003chttps://pypi.python.org/pypi/pip\u003e`_ for the installation steps below.\n\nQgrid depends on the following three Python packages:\n\n    `Jupyter notebook \u003chttps://github.com/jupyter/notebook\u003e`_\n      This is the interactive Python environment in which qgrid runs.\n\n    `ipywidgets \u003chttps://github.com/ipython/ipywidgets\u003e`_\n      In order for Jupyter notebooks to be able to run widgets, you have to also install this ipywidgets package.\n      It's maintained by the Jupyter organization, the same people who created Jupyter notebook.\n\n    `Pandas \u003chttp://pandas.pydata.org/\u003e`_\n      A powerful data analysis / manipulation library for Python.  Qgrid requires that the data to be rendered as an\n      interactive grid be provided in the form of a pandas DataFrame.\n\nThese are listed in `requirements.txt \u003chttps://github.com/quantopian/qgrid/blob/master/requirements.txt\u003e`_\nand will be automatically installed (if necessary) when qgrid is installed via pip.\n\nCompatibility\n-------------\n\n=================  ===========================  ==============================  ==============================\n qgrid             IPython / Jupyter notebook   ipywidgets                      Jupyterlab\n=================  ===========================  ==============================  ==============================\n 0.2.0             2.x                          N/A                             N/A\n 0.3.x             3.x                          N/A                             N/A\n 0.3.x             4.0                          4.0.x                           N/A\n 0.3.x             4.1                          4.1.x                           N/A\n 0.3.2             4.2                          5.x                             N/A\n 0.3.3             5.x                          6.x                             N/A\n 1.0.x             5.x                          7.x                             0.30.x\n=================  ===========================  ==============================  ==============================\n\n\nRunning the demo notebooks locally\n----------------------------------\n\nThere are a couple of demo notebooks in the `qgrid-notebooks \u003chttps://github.com/quantopian/qgrid-notebooks/\u003e`_ repository\nwhich will help you get familiar with the functionality that qgrid provides. Here are the steps to clone the\nqgrid-notebooks repository and open a demo notebook:\n\n#. Install qgrid by following the instructions in the `Installation`_ section above, if you haven't already\n\n#. Clone the qgrid-notebooks repository from GitHub::\n\n    git clone https://github.com/quantopian/qgrid-notebooks.git\n\n#. Install the dev requirements for the repository and start the notebook server::\n\n    cd qgrid-notebooks\n    pip install -r requirements_dev.txt\n    jupyter notebook\n\n#. Click on one of the two notebooks (`index.ipynb \u003chttps://github.com/quantopian/qgrid-notebooks/blob/master/index.ipynb\u003e`_ or `experimental.ipynb \u003chttps://github.com/quantopian/qgrid-notebooks/blob/master/experimental.ipynb\u003e`_) that you see listed in the notebook UI in your browser.\n\nRunning from source \u0026 testing your changes\n------------------------------------------\n\nIf you'd like to contribute to qgrid, or just want to be able to modify the source code for your own purposes, you'll\nwant to clone this repository and run qgrid from your local copy of the repository.  The following steps explain how\nto do this.\n\n#. Clone the repository from GitHub and ``cd`` into the top-level directory::\n\n    git clone https://github.com/quantopian/qgrid.git\n    cd qgrid\n\n#. Install the current project in `editable \u003chttps://pip.pypa.io/en/stable/reference/pip_install/#editable-installs\u003e`_\n   mode::\n\n    pip install -e .\n\n#. Install the node packages that qgrid depends on and build qgrid's javascript using webpack::\n\n    cd js \u0026\u0026 npm install .\n\n#. Install and enable qgrid's javascript in your local jupyter notebook environment::\n\n    jupyter nbextension install --py --symlink --sys-prefix qgrid \u0026\u0026 jupyter nbextension enable --py --sys-prefix qgrid\n\n#. If desired, install the labextension::\n\n    jupyter labextension link js/\n\n#. Run the notebook as you normally would with the following command::\n\n    jupyter notebook\n\nManually testing server-side changes\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nIf the code you need to change is in qgrid's python code, then restart the kernel of the notebook you're in and\nrerun any qgrid cells to see your changes take effect.\n\nManually testing client-side changes\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nIf the code you need to change is in qgrid's javascript or css code, repeat step 3 to rebuild qgrid's npm package,\nthen refresh the browser tab where you're viewing your notebook to see your changes take effect.\n\nRunning automated tests\n^^^^^^^^^^^^^^^^^^^^^^^\nThere is a small python test suite which can be run locally by running the command ``pytest`` in the root folder\nof the repository.\n\nBuilding docs\n^^^^^^^^^^^^^\nThe read-the-docs page is generated using sphinx. If you change any doc strings or want to add something to the\nread-the-docs page, you can preview your changes locally before submitting a PR using the following commands::\n\n    pip install sphinx sphinx_rtd_theme\n    cd docs \u0026\u0026 make html\n\nThis will result in the ``docs/_build/html`` folder being populated with a new version of the read-the-docs site. If\nyou open the ``index.html`` file in your browser, you should be able to preview your changes.\n\nEvents API\n----------\nAs of qgrid 1.0.3 there are new ``on`` and ``off`` methods in qgrid which can be used to attach/detach event handlers. They're available on both the ``qgrid`` module (see `qgrid.on \u003chttps://qgrid.readthedocs.io/en/latest/#qgrid.on\u003e`_), and on individual QgridWidget instances (see `qgrid.QgridWidget.on \u003chttps://qgrid.readthedocs.io/en/latest/#qgrid.QgridWidget.on\u003e`_). Previously the only way to listen for events was to use undocumented parts of the API.\n\nHaving the ability to attach event handlers allows us to do some interesting things in terms of using qgrid in conjunction with other widgets/visualizations. One example is using qgrid to filter a DataFrame that's also being displayed by another visualization.\n\nIf you previously used the ``observe`` method to respond to qgrid events, lets see how your code might be updated to use the new ``on`` method::\n\n    # Before upgrading to 1.0.3\n    def handle_df_change(change):\n        print(change['new'])\n\n    qgrid_widget.observe(handle_df_change, names=['_df'])\n\nWhen you upgrade to 1.0.3, you have more granular control over which events you do an don't listen to, but you can also replicate the previous behavior of calling ``print`` every time the state of the internal DataFrame is changed. Here's what that would look like using the new ``on`` method::\n\n    # After upgrading to 1.0.3\n    def handle_json_updated(event, qgrid_widget):\n        # exclude 'viewport_changed' events since that doesn't change the DataFrame\n        if (event['triggered_by'] != 'viewport_changed'):\n            print(qgrid_widget.get_changed_df())\n\n    qgrid_widget.on('json_updated', handle_json_updated)\n\nSee the `events notebook \u003chttps://mybinder.org/v2/gh/quantopian/qgrid-notebooks/master?filepath=events.ipynb\u003e`_ for more examples of using these new API methods.\n\nFor people who would rather not go to another page to try out the events notebook, here are a couple of gifs to give you an idea of what you can do with it.\n\nThe first gif shows how you can use qgrid to filter the data that's being shown by a matplotlib scatter plot:\n\n        .. figure:: docs/images/linked_to_scatter.gif\n         :align: left\n         :target: docs/images/linked_to_scatter.gif\n         :width: 600px\n\n          A brief demo showing qgrid hooked up to a matplotlib plot\n\nThe second gif shows how you can move qgrid to a separate view in JupyterLab, which makes it more convenient\nto use in conjunction with other visualizations (in this case, a couple of ``Output`` widgets):\n\n        .. figure:: docs/images/events_api.gif\n         :align: left\n         :target: docs/images/events_api.gif\n         :width: 600px\n\n          A brief demo showing qgrid's events api\n\nContinuing to use qgrid 0.3.3\n-----------------------------\nIf you're looking for the installation and usage instructions for qgrid 0.3.3 and the sample notebook that goes\nalong with it, please see the `qgrid 0.3.3 tag \u003chttps://github.com/quantopian/qgrid/tree/v0.3.3\u003e`_ in this\nrepository. The installation steps will be mostly the same. The only difference is that when you run \"pip install\"\nyou'll have to explicitly specify that you want to install version 0.3.3, like this::\n\n  pip install qgrid==0.3.3\n\nIf you're looking for the API docs, you can find them on the\n`readthedocs page for qgrid 0.3.3 \u003chttp://qgrid.readthedocs.io/en/v0.3.3/\u003e`_.\n\nIf you're looking for the demo notebook for 0.3.3, it's still availabe `in nbviewer\n\u003chttp://nbviewer.jupyter.org/gist/TimShawver/8fcef51dd3c222ed25306c002ab89b60\u003e`_.\n\nQgrid 0.3.3 is not compatible with ipywidgets 7, so if you need support for ipywidgets 7, you'll need to use\nqgrid 1.0.\n\nContributing\n------------\nAll contributions, bug reports, bug fixes, documentation improvements, enhancements, and ideas are welcome. See the\n`Running from source \u0026 testing your changes`_ section above for more details on local qgrid development.\n\nIf you are looking to start working with the qgrid codebase, navigate to the GitHub issues tab and start looking\nthrough interesting issues.\n\nFeel free to ask questions by submitting an issue with your question.\n","funding_links":[],"categories":["Python","Tables","交互式小部件和可视化","Visualization","JavaScript","🐍 Python"],"sub_categories":["Useful Python Tools for Data Analysis"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquantopian%2Fqgrid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquantopian%2Fqgrid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquantopian%2Fqgrid/lists"}