Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filtered traitlet #98

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

jchuahtacc
Copy link

Added filtered traitlet which allows python client to retrieve indices of what is currently viewable (after filtering)

@TimShawver
Copy link
Contributor

It seems like your code isn't working with grids that have a Timestamp index. I get the following error when running #2 under Example 1 in the demo notebook https://github.com/quantopian/qgrid/blob/master/qgrid_demo.ipynb

qgrid.show_grid(spy)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-9-7f2f26238472> in <module>()
----> 1 qgrid.show_grid(spy)

/Users/tshawver/repo/qgrid-master/qgrid/grid.pyc in show_grid(data_frame, show_toolbar, remote_js, precision, grid_options)
    205     grid = QGridWidget(df=data_frame, precision=precision,
    206                        grid_options=grid_options,
--> 207                        remote_js=remote_js)
    208 
    209     if show_toolbar:

/Users/tshawver/repo/qgrid-master/qgrid/grid.pyc in __init__(self, *args, **kwargs)
    249         self._selected_rows = []
    250         if self.df is not None:
--> 251             self._update_table()
    252 
    253     def _grid_options_default(self):

/Users/tshawver/repo/qgrid-master/qgrid/grid.pyc in _update_table(self)
    273             df.index.name = 'Index'
    274 
--> 275         self.filtered = df.index.tolist()
    276 
    277         if type(df.index) == pd.core.index.MultiIndex:

/usr/local/lib/python2.7/site-packages/traitlets/traitlets.pyc in __set__(self, obj, value)
    581             raise TraitError('The "%s" trait is read-only.' % self.name)
    582         else:
--> 583             self.set(obj, value)
    584 
    585     def _validate(self, obj, value):

/usr/local/lib/python2.7/site-packages/traitlets/traitlets.pyc in set(self, obj, value)
    570             # we explicitly compare silent to True just in case the equality
    571             # comparison above returns something other than True/False
--> 572             obj._notify_trait(self.name, old_value, new_value)
    573 
    574     def __set__(self, obj, value):

/usr/local/lib/python2.7/site-packages/traitlets/traitlets.pyc in _notify_trait(self, name, old_value, new_value)
   1135             new=new_value,
   1136             owner=self,
-> 1137             type='change',
   1138         ))
   1139 

/usr/local/lib/python2.7/site-packages/ipywidgets/widgets/widget.pyc in notify_change(self, change)
    366                 # Send new state to front-end
    367                 self.send_state(key=name)
--> 368         LoggingConfigurable.notify_change(self, change)
    369 
    370     #-------------------------------------------------------------------------

/usr/local/lib/python2.7/site-packages/traitlets/traitlets.pyc in notify_change(self, change)
   1172                 c = getattr(self, c.name)
   1173 
-> 1174             c(change)
   1175 
   1176     def _add_notifiers(self, handler, name, type):

/Users/tshawver/repo/qgrid-master/qgrid/grid.pyc in filtered_changed(self, change)
    394         self.filtered = [ ]
    395         for index in change['new']:
--> 396             self.filtered.append(int(index))
    397 

TypeError: int() argument must be a string or a number, not 'Timestamp'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants