qgrid icon indicating copy to clipboard operation
qgrid copied to clipboard

Binder demo does not work

Open joncooper opened this issue 4 years ago • 2 comments

Environment

Binder via Chrome on Windows

Description of Issue

  • What did you expect to happen?

Expected the demo Jupyter notebook to work via binder link from project homepage.

  • What happened instead?

See below for traceback.

Reproduction Steps

  1. Visit https://github.com/quantopian/qgrid
  2. Click "launch binder" button under "Click the badge below to try out qgrid using binder:"
  3. Wait for binder to launch Jupyter notebook
  4. Scroll down to "Example 1" cell and Shift-Enter to evaluate it
  5. Cell fails to evaluate with error:
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-ef1f68cba5a6> in <module>
     10     'D' : ["foo", "bar", "buzz", "bippity","boppity", "foo", "foo", "bar", "zoo"] })
     11 df_types['E'] = df_types['D'] == 'foo'
---> 12 qgrid_widget = qgrid.show_grid(df_types, show_toolbar=True)
     13 qgrid_widget

/srv/conda/envs/notebook/lib/python3.7/site-packages/qgrid/grid.py in show_grid(data_frame, show_toolbar, precision, grid_options, column_options, column_definitions, row_edit_callback)
    509                        column_definitions=column_definitions,
    510                        row_edit_callback=row_edit_callback,
--> 511                        show_toolbar=show_toolbar)
    512 
    513 

/srv/conda/envs/notebook/lib/python3.7/site-packages/qgrid/grid.py in __init__(self, *args, **kwargs)
    625 
    626         if self.df is not None:
--> 627             self._update_df()
    628 
    629     def _grid_options_default(self):

/srv/conda/envs/notebook/lib/python3.7/site-packages/qgrid/grid.py in _update_df(self)
    818         self._unfiltered_df = self._df.copy()
    819 
--> 820         self._update_table(update_columns=True, fire_data_change_event=False)
    821         self._ignore_df_changed = False
    822 

/srv/conda/envs/notebook/lib/python3.7/site-packages/qgrid/grid.py in _update_table(self, update_columns, triggered_by, scroll_to_row, fire_data_change_event)
    877                        isinstance(col_series, pd.PeriodIndex)
    878 
--> 879             if type(df.index) == pd.core.index.MultiIndex:
    880                 self._multi_index = True
    881                 for idx, cur_level in enumerate(df.index.levels):

AttributeError: module 'pandas.core' has no attribute 'index'

...

What steps have you taken to resolve this already?

None

Anything else?

The Jupyterlab flavor of the demo also fails

joncooper avatar Apr 22 '20 16:04 joncooper

I just encountered this same problem after installing qgrid. Seems to be a compatibility issue, looks like MultiIndex has moved in Pandas - hence this error. Looking at qgrid/grid.py it seems like this problem is fixed in qgrid v1.3.0. For me PyCharm installed the older 1.1.1 version. I fixed the issue for myself by installing a new version from pip.

0Hughman0 avatar May 10 '20 09:05 0Hughman0

I had the same problem and 0Hughman0's fix worked for me too.

StephieLaPugh avatar Aug 09 '20 19:08 StephieLaPugh