-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
# pandas-qgrid-mixin | ||
|
||
pandas/ipython mix-in to use Qgrid as default DataFrame display method | ||
|
||
## What it does? | ||
|
||
Injects `_ipython_display_` method into `pandas.DataFrame` that instead of the usual HTML table representation shows a `QgridWidget`. | ||
|
||
## Install | ||
|
||
```sh | ||
pip3 install git+git://github.com/0xmjk/pandas-qgrid-mixin | ||
``` | ||
|
||
## Example | ||
|
||
```python | ||
import pandas as pd | ||
import pandas_qgrid_mixin | ||
|
||
pd.DataFrame([{"A": 5, "B": 6}, {"A": 10, "B": 12}]) | ||
``` | ||
|
||
![png](screenshot.png) | ||
|
||
## Options | ||
|
||
Additional `pandas.display` options: | ||
|
||
| Option | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| pandas.display.use_qgrid_doc | bool | True | Display DataFrames using QgridWidget instead of default HTML. | | ||
| pandas.display.show_qgrid_options_doc | dict | {}| Kwargs for grid.show_grid() | | ||
|
||
## Links | ||
|
||
* [Qgrid](https://github.com/quantopian/qgrid) is an interactive grid for sorting, filtering, and editing DataFrames in Jupyter notebooks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from IPython.display import display, HTML | ||
import qgrid | ||
import pandas as pd | ||
|
||
def DataFrame_ipython_display_(self): | ||
use_qgrid = False | ||
show_qgrid_options = {} | ||
try: | ||
use_qgrid = pd.options.display.use_qgrid | ||
show_qgrid_options = pd.options.display.show_qgrid_options.d | ||
except Exception: | ||
pass | ||
|
||
if use_qgrid: | ||
widget = qgrid.show_grid(self, **show_qgrid_options) | ||
return widget._ipython_display_() | ||
else: | ||
return display(HTML(self._repr_html_())) | ||
|
||
pd.DataFrame._ipython_display_ = DataFrame_ipython_display_ | ||
use_qgrid_doc = """ | ||
: bool | ||
Display DataFrames using QgridWidget instead of default HTML. | ||
""" | ||
show_qgrid_options_doc = """ | ||
: dict | ||
Kwargs for qgrid.show_grid() | ||
""" | ||
pd.core.config.register_option("display.use_qgrid", True, doc=use_qgrid_doc) | ||
pd.core.config.register_option("display.show_qgrid_options", {}, doc=show_qgrid_options_doc) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from setuptools import setup | ||
|
||
setup( | ||
name='pandas-qgrid-mixin', | ||
install_requires=['pandas', 'qgrid', 'ipython>=4.0.0'], | ||
version='0.1', | ||
description='pandas/ipython mix-in to use qgrid as default DataFrame display method', | ||
url='http://github.com/0xmjk/pandas-qgrid-mixin', | ||
license='Apache-2.0', | ||
packages=['pandas_qgrid_mixin'], | ||
zip_safe=False) |