quantopian / qgrid Goto Github PK
View Code? Open in Web Editor NEWAn interactive grid for sorting, filtering, and editing DataFrames in Jupyter notebooks
License: Apache License 2.0
An interactive grid for sorting, filtering, and editing DataFrames in Jupyter notebooks
License: Apache License 2.0
When the Notebook server is run with a custom prefix, the local cdn_base_url is incorrect and hence show_grid(..., remote_js=False)
does not work.
I have a qgrid that contains $ amounts that I would like to have displayed with commas separators but if I change the value types from float to string, the columns do not sort properly. How can i get around this?
Are there any plan to support 3.4/5?
I am using Python 2.7.8 and Jupyter 4.0.6 on CENTOS 6. I use the following code to render qgrid.
"import qgrid
qgrid.show_grid(df)"
In some cases it works with no issue. Although with wider df's I get a "kernel restarting" error on Jupyter which states "The kernel appears to have died. It will restart automatically". This is the only time I've had this occur on Jupyter (when I use qgrid).
I was able to fix this by changing my PANDAS dataframe column types FROM 'category'. It seems qgrid crashes when trying to render PANDAS 'category' data types?
Further, with PANDAS datetime column types, it does not display the 'time' part of the field.
Hi,
Is it possible to show a DataFrame where the columns are a MultiIndex such as:
A C
1 2 3 1 2 3
X -0.890096 0.076550 -0.686891 0.985743 -0.426691 -0.577464
Y -1.059743 -2.835858 -0.389842 -0.316724 0.102168 -0.932888
Thanks,
Damien G.
It would be awesome if qgrid would respect the pandas display options like max_rows, max_cols etc.
Using the IPython display architecture you can register functions that are automatically called when a DataFrame
is displayed. This will enable users to optionally enable qgrid
to display DataFrame
by default, without an extra call. Running on a plane now, but please ping the ipython devs (or me later) on how this can be done. Awesome work!
I love the idea of sorting and filtering my dataframes in the notebooks directly. i tried to install qgrid on my local and on a remote system on jupyterhub. without success.
what i did
I did pip3 install qgrid
and after importing qgrid I tried a qgrid.show_grid(df)
right away. no success, no output.
so i additionally ran: qgrid.nbinstall(overwrite=True)
i read about in the demo.
symptoms are
jupyter notebook
instead of jupyterhub on my local system it works and everything is loaded correctlyshow_grid
with show_toolbar=True
parameter and click on Export. qgrid is loaded all of a sudden and everything is loaded.any idea where i can look into? thanks
I am trying to load a qgrid from a pandas dataframe, but when I run:
import qgrid
import pandas as pd
df=pd.DataFrame([dict(idx=0,A=1),dict(idx=2,A=2)])`
Nothing happens (no error or anything else). Here are errors listed in my JS console:
Couldn't create a view for model id 'd7522ce5e25148848c5e49c7fdf8f795' -- TypeError: require is not a function(…)
(anonymous function) @ utils.js:760
z @ VM218:22R @ VM218:22
(anonymous function) @ VM218:22
g @ VM218:22utils.js:760 Could not create view -- WrappedError {stack: "Error: Couldn't create a view for model id 'd7522c…39d168d24e1b201697c328:1:0), :22:8069)", message: "Couldn't create a view for model id 'd7522ce5e25148848c5e49c7fdf8f795'", error_stack: Array[3]}(anonymous function) @ utils.js:760
z @ VM218:22
R @ VM218:22
C @ VM218:22T @ VM218:22
g @ VM218:22utils.js:760 Could not display model -- WrappedError {stack: "Error: Could not create view↵ at new Error (nat…39d168d24e1b201697c328:1:0), :22:8069)", message: "Could not create view", error_stack: Array[4]}(anonymous function) @ utils.js:760
z @ VM218:22
R @ VM218:22
C @ VM218:22T @ VM218:22
g @ VM218:22
Just wondering if there will be support for slick grid's column options.
Is it possible that the (numeric) column filter selections make it possible to show updated column totals somewhere automatically?
I am using runipy to run a ipython notebook and save the notebook output as a new notebook. Qgrid is working properly when running notebook on jupyterhub, but doesn't work when using runipy. Code is executed properly, only qgrid is not displayed instead it displays following
var path_dictionary = { jquery_drag: "https://cdn.rawgit.com/quantopian/qgrid/72d356cb123fab413dba73ec46616e4916fbd827/qgrid/qgridjs//lib/jquery.event.drag-2.2", slick_core: "https://cdn.rawgit.com/quantopian/qgrid/72d356cb123fab413dba73ec46616e4916fbd827/qgrid/qgridjs//lib/slick.core.2.2", slick_data_view: "https://cdn.rawgit.com/quantopian/qgrid/72d356cb123fab413dba73ec46616e4916fbd827/qgrid/qgridjs//lib/slick.dataview.2.2", slick_check_box_column: "https://cdn.rawgit.com/quantopian/qgrid/72d356cb123fab413dba73ec46616e4916fbd827/qgrid/qgridjs//lib/slick.checkboxselectcolumn", slick_row_selection_model: "https://cdn.rawgit.com/quantopian/qgrid/72d356cb123fab413dba73ec46616e4916fbd827/qgrid/qgridjs//lib/slick.rowselectionmodel", slick_grid: "https://cdn.rawgit.com/quantopian/qgrid/72d356cb123fab413dba73ec46616e4916fbd827/qgrid/qgridjs//lib/slick.grid.2.2", data_grid: "https://cdn.rawgit.com/quantopian/qgrid/72d356cb123fab413dba73ec46616e4916fbd827/qgrid/qgridjs//qgrid", date_filter: "https://cdn.rawgit.com/quantopian/qgrid/72d356cb123fab413dba73ec46616e4916fbd827/qgrid/qgridjs//qgrid.datefilter", slider_filter: "https://cdn.rawgit.com/quantopian/qgrid/72d356cb123fab413dba73ec46616e4916fbd827/qgrid/qgridjs//qgrid.sliderfilter", text_filter: "https://cdn.rawgit.com/quantopian/qgrid/72d356cb123fab413dba73ec46616e4916fbd827/qgrid/qgridjs//qgrid.textfilter", filter_base: "https://cdn.rawgit.com/quantopian/qgrid/72d356cb123fab413dba73ec46616e4916fbd827/qgrid/qgridjs//qgrid.filterbase", handlebars: "https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0/handlebars.min" }; var existing_config = require.s.contexts._.config; if (!existing_config.paths['underscore']){ path_dictionary['underscore'] = "https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.7.0/underscore-min"; } if (!existing_config.paths['moment']){ path_dictionary['moment'] = "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.3/moment.min"; } if (!existing_config.paths['jqueryui']){ path_dictionary['jqueryui'] = "https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min"; } require.config({ paths: path_dictionary }); if (typeof jQuery === 'function') { define('jquery', function() { return jQuery; }); } require([ 'jquery', 'jquery_drag', 'slick_core', 'slick_data_view' ], function(){('#b97d5b3e-85fe-4920-8635-2e5ddd467eff').closest('.rendered_html').removeClass('rendered_html'); require([ 'slick_check_box_column', 'slick_row_selection_model', 'slick_grid' ], function(){ require(["data_grid"], function(dgrid){ var grid = new dgrid.QGrid('#b97d5b3e-85fe-4920-8635-2e5ddd467eff',
As far as I can see, the show_toolbar
option isn't available on the latest released version. Could you do another release?
Would make it possible to pip install qgrid
without having to have git installed.
Hi,
In the example at nbviewer, there are also filter icons displayed for non-numeric columns, which does not happen on my local install.
Would you know why this is the case? May it be because the the qgrid.nbinstall()
command gives the following error: PermissionError: [Errno 13] Permission denied: '/usr/local/share/jupyter'
? It seems to work fine otherwise (and I am not sure why this nbinstall() needs to be run.
Thanks for any help!
I'm trying to make a cell clickable the value is http://link.com this question explains how to do it for slickgrid: http://stackoverflow.com/questions/9840548/how-to-put-html-into-slickgrid-cell
Any pointers how this would work with qgrid / ipython?
Thanks
Hello,
is this scenario possible:
df_new = qgrid.show_grid(df, remote_js = True)
plt.scatter(df_new.index, dataframe['Col'])
In the essence, it would be great to have the df_new and the plot created from it updated interactively.
Sorry, i'm pretty new to javascript. How does qgrid tell ipython notebook which js files to load?
The only place i could find any kind of "import" statement was in the slickgrid.js.template file:
var path_dictionary = {{
jquery_drag: "{cdn_base_url}/lib/jquery.event.drag-2.2",
slick_core: "{cdn_base_url}/lib/slick.core.2.2",
slick_data_view: "{cdn_base_url}/lib/slick.dataview.2.2",
slick_check_box_column: "{cdn_base_url}/lib/slick.checkboxselectcolumn",
slick_row_selection_model: "{cdn_base_url}/lib/slick.rowselectionmodel",
slick_grid: "{cdn_base_url}/lib/slick.grid.2.2",
data_grid: "{cdn_base_url}/qgrid",
data_grid_bb: "{cdn_base_url}/qgrid.bb",
date_filter: "{cdn_base_url}/qgrid.datefilter",
slider_filter: "{cdn_base_url}/qgrid.sliderfilter",
text_filter: "{cdn_base_url}/qgrid.textfilter",
filter_base: "{cdn_base_url}/qgrid.filterbase",
handlebars: "https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0/handlebars.min"
}};
however, if i add a js file to this path, it does not appear to load in the browser. Is there something else that needs to be modified for a JS file to load?
There's a critical patch in the master, namely that installation does not require superuser privileges. I think upgrading the qgrid
that's avail on pypi would make installation much easier.
I have the following:
jupyter==1.0.0
jupyter-client==4.2.2
jupyter-console==4.1.1
jupyter-core==4.1.0
ipywidgets==4.1.1
widgetsnbextension==1.2.3
When I try to run the 5 cell in the demo notebook I got
[IPKernelApp] ERROR | No such comm target registered: jupyter.widget.version
How to make edits permanent? The demo notebook suggests a grid is editable by default, and that the dataframe is updated.
I may be missing something very obvious but I can't seem to make my edits to a dataframe permanent using qgrid . I'm basically following he demo notebook. The dataframe displays nicely when I call
qgrid.show_grid(df)
I can click on cells to change values. Those new values continue to display in that grid as I move around. However when I run the code to display the same dataframe again from the same cell for from a cell lower down in my notebook, all my edits appear to be lost. I just see the content of the original dataframe.
Is there some setting I need to change? The qgrid documentation states these settings are passed to slickgrid
{
'fullWidthRows': True,
'syncColumnCellResize': True,
'forceFitColumns': True,
'rowHeight': 28,
'enableColumnReorder': False,
'enableTextSelectionOnCells': True,
'editable': True,
'autoEdit': False
}
Should any of these be different?
The version currently available on pypi force-downgrades several packages. It would be nice to update to the current version on pypi, which has fixed requirements.txt, so this doesn't happen anymore.
Is it possible to add color to grid cells?
In other words is there an option such as index=False in df.to_csv(path, index=False)?
Thanks a lot for the wonderful and very useful wrapper!
Marko
Hello, this is a partial bug message, I figured it was worth filing in case others have a similar issue. I have an existing Python 3.4 Anaconda environment called "scratch" (I use it for all side projects). It has numpy, pandas, IPython Notebook and lots more.
I already had a version of qgrid from at least 6 months back, installed back in the mists of time.
I just tried pip install -U git+https://github.com/quantopian/qgrid
(adding -U
to your install notes) and it had a crack at uninstalling my Anaconda-provided numpy+pandas+notebook. I killed it and thankfully it hadn't nuked my environment.
I cloned your repo locally and edited setup.py
to remove the install_requires
dependencies, then ran python setup.py install
and I have the latest version. I'm not sure what happened but I figure it is worth noting (but feel free to close/delete if this isn't a helpful-enough bug report!).
Don't know if this is a limitation of SlickGrid or qgrid. Is it possible or are you planning to allow filtering of non-numeric content in columns?
I created a QGrid IPython Widget (valid for IPython 3.x). It adds the ability to edit the dataframe in-place, including adding and removing rows. It requires no changes to the existing codebase.
Are you interested in a PR that adds this widget?
I'm not sure what the best way to package it would be. Perhaps a qgrid.prepare_notebook()
that loads qgrid_widget.js
using IPython.display.Javascript
. You could then expose qgrid.QGridWidget
as well as qgrid.edit_dataframe()
, that runs the application with the add/remove row buttons and returns the modified dataframe.
This is useful for standalone web apps.
There should be away to either obtain a div
and js
or simply to have a filter for piping dataframe
s via jinja.
Right now, defaults are handled outside the QGridWidget
class. Thus, if you try to instantiate a QGridWidget
it fails as it doesn't have the right default args. In general Widgets should manage their own defaults internally. It is not difficult to set this up using traitlets and we probably don't have to break any APIs.
Is it possible to scroll within the autofilter selection page? i.e. when i select the autofilter, only a subset of the items in the column are listed and there does not appear to be a way to scroll within that list.
Right now the QGridWidget
sizes itself in wonky ways. It actually extends beyond that edge of the widget area. The main thing is to setup the sizing such that:
ping @aggFTW
http://nbviewer.jupyter.org/gist/TimShawver/b4bc80d1128407c56c9a
Just compare the Date column/index for the dataframe and qgrid. For some reason it gets offset by 1 day which is wrong.
Hi there,
since a few days (guess new release) I get this when doing my standard upgrade-check on the module (using latest anaconda 3.5 on latest mac osx).
| => pip install qgrid --upgrade --no-deps
Collecting qgrid
Using cached qgrid-0.3.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/bs/gk3rhfzd2475g9vx5wlcqqb40000gn/T/pip-build-lq0rtygo/qgrid/setup.py", line 27, in <module>
reqs = read_requirements('requirements.txt')
File "/private/var/folders/bs/gk3rhfzd2475g9vx5wlcqqb40000gn/T/pip-build-lq0rtygo/qgrid/setup.py", line 24, in read_requirements
with open(reqs_file) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/private/var/folders/bs/gk3rhfzd2475g9vx5wlcqqb40000gn/T/pip-build-lq0rtygo/qgrid/requirements.txt'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/bs/gk3rhfzd2475g9vx5wlcqqb40000gn/T/pip-build-lq0rtygo/qgrid
qgrid.nbinstall() # copies javascript dependencies to your /nbextensions folder
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-2-ca03556e1713> in <module>()
----> 1 qgrid.nbinstall() # copies javascript dependencies to your /nbextensions folder
C:\Python\Python27\lib\site-packages\qgrid\__init__.pyc in nbinstall(user, overwrite)
23 user=user,
24 symlink=False,
---> 25 verbose=0,
26 )
TypeError: install_nbextension() got an unexpected keyword argument 'user'
Will fix issues like #16.
I'm putting this here both as an issue for potential fixing, and a warning to others who might burn a whole day trying to debug this. qgrid will not work with version 5+ of ipywidgets. There has been significant code refactoring, and the relevant javascript that's used by qgrid is no longer where expected. I've spent a little time looking into what it would take to update qgrid to work with ipywidgets 5+, but am not familiar enough with the codebases to have a good feel for how difficult the task will be.
What if we used:
https://cdn.rawgit.com/quantopian/qgrid/master/qgrid/qgridjs/
And then substituted "master" for the current git hash as part of a release script? I can provide a PR with a Makefile that handles releases based on this one: https://github.com/blink1073/oct2py/blob/master/Makefile#L30
I would like my qgrid
tables to render on nbviewer.
I reran qgrid_demo.ipynb
and the tables in the resulting notebook did not show up in nbviewer.
Here are the details of my installed packages.
Hi,
thanks for this great extension!
I was wondering if copying data from qgrid table is possible, and if so how?
In Chrome, if I try to select some table cells it simple has no effect.
In Firefox, I'm able to select cells while dragging the mouse with left mouse button being pressed, but as soon as I release the left mouse button, selection disappears, and I'm not able to copy any data.
Collecting qgrid
Downloading qgrid-0.3.1.tar.gz (71kB)
100% |████████████████████████████████| 81kB 300kB/s
Requirement already up-to-date: notebook==4.1.0 in /usr/lib/python2.7/site-packages (from qgrid)
Collecting pandas==0.17.1 (from qgrid)
Downloading pandas-0.17.1.zip (7.7MB)
17% |█████▌ | 1.3MB 97kB/s eta 0:01:06^Z
[1]+ Stopped pip install --upgrade qgrid
I have pandas 18.1 installed qgrid is downgrading pandas... please fix.
pip list
pandas (0.18.1)
Howdy,
I have a notebook where the following correctly displays a table:
df = pd.DataFrame([1,2,3,4])
qgrid.show_grid(df)
However, when I try to display a denser dataframe in the same notebook, the output shows, but is removed on page refresh, while the above continues to display correctly. Is there some sort of limit to how big the dataframe can be? Any other potential cause for this? I can't release the dataset that's causing this. Some ideas for possible causes would be great so I can make a reproducible case.
Edit: was able to repro the issue by repeatedly displaying a dataframe with of dimensions around 15x100. 3 times seems to do the trick to cause failure.
Seems like it was dataframe size related after all:
WrappedError {stack: "Error: Could not call widget save state callback.↵…in.js?v=40e10638fcf65fc1c057bff31d165e9d:12785:33", message: "Could not call widget save state callback.", error_stack: Array[2]}
error_stack: Array[2]
0: DOMException: Failed to set the 'widgets:http://192.168.1.113:8888/notebooks/qqgrid%20test.ipynb' property on 'Storage': Setting the value of 'widgets:http://192.168.1.113:8888/notebooks/qqgrid%20test.ipynb' exceeded the quota. at Error (native) at null.<anonymous> (http://192.168.1.113:8888/nbextensions/widgets/widgets/js/manager.js?v=20151223164406:523:27) at http://192.168.1.113:8888/nbextensions/widgets/widgets/js/manager.js?v=20151223164406:454:35
code: 22
message: "Failed to set the 'widgets:http://192.168.1.113:8888/notebooks/qqgrid%20test.ipynb' property on 'Storage': Setting the value of 'widgets:http://192.168.1.113:8888/notebooks/qqgrid%20test.ipynb' exceeded the quota."
name: "QuotaExceededError"
stack: "Error: Failed to set the 'widgets:http://192.168.1.113:8888/notebooks/qqgrid%20test.ipynb' property on 'Storage': Setting the value of 'widgets:http://192.168.1.113:8888/notebooks/qqgrid%20test.ipynb' exceeded the quota.↵ at Error (native)↵ at null.<anonymous> (http://192.168.1.113:8888/nbextensions/widgets/widgets/js/manager.js?v=20151223164406:523:27)↵ at http://192.168.1.113:8888/nbextensions/widgets/widgets/js/manager.js?v=20151223164406:454:35"
It might be nice to be able to spit out a separate HTML file that works independently of the notebook. This would allow one to share the HTML file easily without requiring iPython/Jupyter.
The following code seems to throw some javascript errors when I click on Add/Remove Rows:
Selection and Editing still seem to work fine.
This is using python 2.7, IPython 4.1.1 and master branch of qgrid.
import qgrid
import IPython
print IPython.__version__
import pandas
import numpy as np
res = pandas.DataFrame(np.arange(20).reshape(10,2))
res.index = np.arange(len(res))
qgrid.nbinstall(overwrite=True)
qgrid.show_grid(res, show_toolbar=True)
The exception I see in the chrome js console reads:
Exception in Comm callback Each data element must implement a unique 'id' property undefined Object {parent_header: Object, msg_type: "comm_msg", msg_id: "b14613d9-f5a9-4c99-bc7e-3d8516296885", content: Object, header: Object…}buffers: Array[0]channel: "iopub"content: Objectcomm_id: "83a82de5e21e4a588d83b7d054924db6"data: Objectcontent: Objectmethod: "custom"proto: Object__proto__: Objectheader: Objectmetadata: Object__proto__: Objectmsg_id: "b14613d9-f5a9-4c99-bc7e-3d8516296885"msg_type: "comm_msg"parent_header: Object__proto__: Object
Any thoughts?
I have GitHub for windows installed but the pip install instructions in the demo notebook didn't work for me (cannot find command 'git'). Could you help? Looks like a very cool project.
Fantastic project, my team's been meaning to create something like this for months now. Kudos!!
The DataFrames we're working with tend to have many columns (100+). Currently, when I render a qgrid it looks like this:
It would be great for us to have an option that does not limit the qgrid width to your browser, and instead overflows horizontally. You'd still see all columns, but you'd need to scroll (like in Excel).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.