Giter VIP home page Giter VIP logo

Comments (17)

ssanderson avatar ssanderson commented on July 18, 2024

@ellisonbg sounds good. Would the basic expected syntax be something like:

import qgrid

qgrid.register_displayhook()

# Displays with qgrid automatically.
pd.DataFrame(...)

from qgrid.

TimShawver avatar TimShawver commented on July 18, 2024

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.

ellisonbg avatar ellisonbg commented on July 18, 2024

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.

TimShawver avatar TimShawver commented on July 18, 2024

Awesome, thanks @ellisonbg!

from qgrid.

ellisonbg avatar ellisonbg commented on July 18, 2024

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.

ellisonbg avatar ellisonbg commented on July 18, 2024

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.

TimShawver avatar TimShawver commented on July 18, 2024

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.

ellisonbg avatar ellisonbg commented on July 18, 2024

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.

TimShawver avatar TimShawver commented on July 18, 2024

Yep that sounds reasonable. Thanks again for the help.

from qgrid.

ssanderson avatar ssanderson commented on July 18, 2024

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.

ellisonbg avatar ellisonbg commented on July 18, 2024

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.

ssanderson avatar ssanderson commented on July 18, 2024

Opened up an issue in the main IPython repo here: ipython/ipython#6687.

from qgrid.

ellisonbg avatar ellisonbg commented on July 18, 2024

Here is the code that can do this:

https://gist.github.com/ellisonbg/5c54f995bfcd64b90dc2

from qgrid.

ellisonbg avatar ellisonbg commented on July 18, 2024

ping @aggFTW

from qgrid.

ssanderson avatar ssanderson commented on July 18, 2024

@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.

ssanderson avatar ssanderson commented on July 18, 2024

(The other option would be to enable this by default as an import-time side effect, but that feels too aggressive.)

from qgrid.

TimShawver avatar TimShawver commented on July 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.