Comments (17)
@ellisonbg sounds good. Would the basic expected syntax be something like:
import qgrid
qgrid.register_displayhook()
# Displays with qgrid automatically.
pd.DataFrame(...)
from qgrid.
I think the registration code is explained in the same Custom Display Logic example notebook I used a bunch:
http://nbviewer.ipython.org/github/ipython/ipython/blob/master/examples/IPython%20Kernel/Custom%20Display%20Logic.ipynb
Based on that example I think our registration code would look something like this:
ip = get_ipython()
html_f = ip.display_formatter.formatters['text/html']
html_f.for_type_by_name('pandas', 'DataFrame', show_grid_function)
from qgrid.
Yep, here is the code I am using in a different library to define an automatic display function for numpy arrays:
def enable():
"""Enable automatic visualization of NumPy arrays in the IPython Notebook."""
try:
from IPython.core.getipython import get_ipython
except ImportError:
raise ImportError('This feature requires IPython 1.0+')
ip = get_ipython()
f = ip.display_formatter.formatters['text/html']
f.for_type(np.ndarray, _array_to_html)
def disable():
"""Disable automatic visualization of NumPy arrays in the IPython Notebook."""
try:
from IPython.core.getipython import get_ipython
except ImportError:
raise ImportError('This feature requires IPython 1.0+')
ip = get_ipython()
f = ip.display_formatter.formatters['text/html']
f.type_printers.pop(np.ndarray, None)
The naming of these types of functions tends to be something like enable/disable
or enable_notebook/disable_notebook
. These function are also a good place to load the JS on the page as well.
from qgrid.
Awesome, thanks @ellisonbg!
from qgrid.
Question - do you always send the entire data back to the browser? Do you
allow for the setting of an upper limit on the size of the data that can be
send back? Sending a huge dataframe to the browser would definitely kill
things...
Then there is a question of how you subsample the frame...
On Sat, Oct 11, 2014 at 3:38 PM, Tim Shawver [email protected]
wrote:
Awesome, thanks @ellisonbg https://github.com/ellisonbg!
—
Reply to this email directly or view it on GitHub
#8 (comment).
Brian E. Granger
Cal Poly State University, San Luis Obispo
@ellisonbg on Twitter and GitHub
[email protected] and [email protected]
from qgrid.
Also, this should be pretty easy to turn into a widget that allows data to
be edited in the widget and saved in the DataFrame...
On Sat, Oct 11, 2014 at 3:41 PM, Brian Granger [email protected] wrote:
Question - do you always send the entire data back to the browser? Do you
allow for the setting of an upper limit on the size of the data that can be
send back? Sending a huge dataframe to the browser would definitely kill
things...Then there is a question of how you subsample the frame...
On Sat, Oct 11, 2014 at 3:38 PM, Tim Shawver [email protected]
wrote:Awesome, thanks @ellisonbg https://github.com/ellisonbg!
—
Reply to this email directly or view it on GitHub
#8 (comment).Brian E. Granger
Cal Poly State University, San Luis Obispo
@ellisonbg on Twitter and GitHub
[email protected] and [email protected]
Brian E. Granger
Cal Poly State University, San Luis Obispo
@ellisonbg on Twitter and GitHub
[email protected] and [email protected]
from qgrid.
Currently I do always send all of the data back, and yes a huge DataFrame will freeze the UI (I think the limit is around 50K rows right now). I like the idea of allowing people to set an upper limit on the amount of data.
Writing back to the DataFrame would be awesome. SlickGrid does support editing cells so it's probably not a ton of work.
from qgrid.
OK, maybe add a set_limit()
function (for the automatic display) and a
limit kwarg for explicit display and then play around with what a good
default should be?
To get the write back, we will have to figure out how to tie it into the
widget fraemwork as well. Shouldn't be too bad, we have been meaning to
figure out how to have a single object that can work as display and
widget...
Cheers,
Brian
On Sat, Oct 11, 2014 at 4:03 PM, Tim Shawver [email protected]
wrote:
Currently I do always send all of the data back, and yes a huge DataFrame
will freeze the UI (I think the limit is around 50K rows right now). I like
the idea of allowing people to set an upper limit on the amount of data.Writing back to the DataFrame would be awesome. SlickGrid does support
editing cells so it's probably not a ton of work.—
Reply to this email directly or view it on GitHub
#8 (comment).
Brian E. Granger
Cal Poly State University, San Luis Obispo
@ellisonbg on Twitter and GitHub
[email protected] and [email protected]
from qgrid.
Yep that sounds reasonable. Thanks again for the help.
from qgrid.
One thing that's tricky here is that we're currently using both display_html
and display_javascript
inside the _ipython_display_
method for SlickGrid
, and the automatic display logic above relies on the output only having one mimetype. My guess is the fix for this is to combine the html and javascript into a single html chunk by putting the javascript pieces in a <script>
block.
from qgrid.
Ahh, what we really need to do is have a display function registration for
the _ipython_display_
method as well. Can you open an issue and ping
@minrk on that.
On Sun, Oct 12, 2014 at 4:35 AM, Scott Sanderson [email protected]
wrote:
One thing that's tricky here is that we're currently using both
display_html and display_javascript inside the ipython_display method
for SlickGrid, and the automatic display logic above relies on the output
only having one mimetype. My guess is the fix for this is to combine the
html and javascript into a single html chunk by putting the javascript
pieces in a <script> block.—
Reply to this email directly or view it on GitHub
#8 (comment).
Brian E. Granger
Cal Poly State University, San Luis Obispo
@ellisonbg on Twitter and GitHub
[email protected] and [email protected]
from qgrid.
Opened up an issue in the main IPython repo here: ipython/ipython#6687.
from qgrid.
Here is the code that can do this:
https://gist.github.com/ellisonbg/5c54f995bfcd64b90dc2
from qgrid.
ping @aggFTW
from qgrid.
@ellisonbg do you have thoughts on what a reasonable API for enabling this would be?
Presumably it'd be something like:
from qgrid import autouse
# Internally sets a display formatter for DataFrame and/or Series
autouse()
where the signature of autouse would be something like:
def autouse(autouse_dataframe=True, autouse_series=<what should this be?>):
from qgrid.
(The other option would be to enable this by default as an import-time side effect, but that feels too aggressive.)
from qgrid.
Finally got some time to do some dev work on qgrid and I included the automatic display capability in the new qgrid 1.0 beta. There are two new methods enable
and disable
. Here are the docs for these functions: http://qgrid.readthedocs.io/en/latest/#qgrid.enable
I don't think I'll have to add a set_limit
function anymore because I ended up implementing "virtual scrolling" so that we only send 200 or so rows down to the browser at a time (which means qgrid can render very large DataFrames now).
See the installation instructions on the readme if you'd like to try out the new beta.
from qgrid.
Related Issues (20)
- grid does not support add_rows on an empty dataframe. Could we stop the user from removing the last row?
- qgrid incompatible with ipywidgets==8.0.0a6 due to decorator usage HOT 1
- Qgrid working with Modern Jupyter Lab (3.2 and beyond)
- Set Formatter for Column Definitions
- AttributeError: 'DataFrame' object has no attribute 'map'
- [Security] Workflow main.yml is using vulnerable action actions/checkout
- missing 1 required positional argument: 'widget' HOT 3
- qgrid not working in Binder notebook
- update for ipywidgets 8 compatibility HOT 1
- qgrid post link fails on environment build HOT 2
- REPO IS NO LONGER MAINTAINED AND DOES NOT SUPPORT JUPYTERLAB>=3.0.0 HOT 8
- QGrid is not working with NB-viewer.
- Internet connection required for qgrid 1.1.3 HOT 1
- Here, working version HOT 12
- filter_changed is not recognised in .on() HOT 1
- "ImportError: cannot import name 'Mapping' from 'collections' (C:\ProgramData\anaconda3\lib\collections\__init__.py)"
- post-link script failed for package conda-forge::qgrid-1.3.1-py39hcbf5309_2
- Filter not working HOT 1
- Detecting row selected in Python shiny
- Cannot edit the table using responsive setting
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qgrid.