Qgrid extended

Qgrid is a Jupyter notebook widget which uses SlickGrid to render pandas DataFrames within a Jupyter notebook. This allows you to explore your DataFrames with intuitive scrolling, sorting, and filtering controls, as well as edit your DataFrames by double clicking cells.

This extention includes helper classes to quickly integrate in the Module Core. Also, Apps can inherit the Grid abstract class to detail views in Jupyter Notebook.

Qgrid Usage

Basic usage is by calling from core:

from ozcore import core

core.gridq.view(df, handler=True, minor=None)

For consuming abstract class in Apps:

from ozcore.core.qgrid.grid import Grid

class MySampleClass:
    ....
    def grid(self):
        # call grid's inner class
        _grid = self._View()
        _grid.view(df_slice=self.df)

    class _View(Grid):
        # inner class to inherit core > qgrid > view method

        def __init__(self, cards=False):
            super().__init__()

        def _handler_view_selection_changed(self, event, qgrid_widget):
        # ....  override handler

        def edit()
        # .... override edit

Qgrid Class Methods

qgrid abstract class

class ozcore.core.qgrid.grid.Grid[source]

abstract class for calling qgrid

inherits:

Base class View class

\* view

displays with settings in Base class

\* edit

abstract method, to be implemented

helper methods:
_handler_view_selection_changed()
already implemented in View class, can be altered by re-defining

usage:

# simple usage:
from ozcore import core
core.gridq.view(dataframe)

# integrate with inner class:
from ozcore.core.qgrid_.grid import Grid

class MySampleClass:
    ....
    def grid(self):
        # call grid's inner class
        _grid = self._View()
        _grid.view(df_slice=self.df)

    class _View(Grid):
        # inner class to inherit core > qgrid > view method

        def __init__(self, cards=False):
            super().__init__()

        def _handler_view_selection_changed(self, event, qgrid_widget):
        # ....  override handler
        def edit()
        # .... override edit
__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

edit(df_slice, **kwargs)[source]

edit qgrid fields

NotImplemented

_clean_qgrid_js()

Javascript injection for qgrid

Returns

  • JS integrated in Jupyter Notebook for Qgrid

  • removes default buttons,

  • adds a js button,

  • adds js to scroll action of qgrid

_display_qgrid(q)

build qgrid display for Jupyter Notebook

usage:

q = self._qgrid(df_slice=df_slice, **kwargs)
display_qgrid(q)

# define before any headers to receive qgrid info, e.g. shape
_handler_view_selection_changed(event, qgrid_widget)

event handler for view when qgrid on selection_changed

Returns

displays selected row in footer single rec Output

_qgrid(df_slice=None, minor=None, **kwargs)

Custom qgrid wrapper

Parameters
  • df_slice – Dataframe to be displayed

  • minor – list, columns to display

  • kwargs – arguments for qgrid settings

_set_grid_options(**kwargs)

qgrid grid_options kwargs apply to values

Parameters

kwargs – option values are updated by kwargs

usage:

grid_options(editable=True)
view(df_slice, handler=True, minor=None, **kwargs)
display dataframe with qgrid

qgrid display settings defined in inherited Base class

Parameters
  • df_slice – Dataframe to be displayed

  • handler – bool, default True, turns on/off preview below grid

  • minor – list, columns to display, default None

Keyword Arguments
  • show_toolbar – bool, default True

  • sortable – bool, default True, causes glitch with editable

  • filterable – bool, default True, causes glitch with editable

  • forceFitColumns – bool, default True

  • rowHeight – int, default 70

  • defaultColumnWidth – int, default 150

  • maxVisibleRows – int, default 15

  • minVisibleRows – int, default 8

  • height – str, default “250px”

Returns

Jupyter Notebook display with a header, qgrid, footer and selected record block

usage:

from ozcore import core
core.grid.view(core.dummy.emp, rowHeight=30, handler=False)