diff --git a/js/package.json b/js/package.json index f6861196..195c7dea 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "qgrid", - "version": "1.0.3", + "version": "1.0.5", "description": "An Interactive Grid for Sorting and Filtering DataFrames in Jupyter Notebook", "author": "Quantopian Inc.", "main": "src/index.js", diff --git a/js/src/qgrid.widget.js b/js/src/qgrid.widget.js index 32d9a832..06bafa21 100644 --- a/js/src/qgrid.widget.js +++ b/js/src/qgrid.widget.js @@ -36,8 +36,8 @@ class QgridModel extends widgets.DOMWidgetModel { _view_name : 'QgridView', _model_module : 'qgrid', _view_module : 'qgrid', - _model_module_version : '^1.0.3', - _view_module_version : '^1.0.3', + _model_module_version : '^1.0.5', + _view_module_version : '^1.0.5', _df_json: '', _columns: {} }); diff --git a/qgrid/_version.py b/qgrid/_version.py index 2921a0c3..50954c41 100644 --- a/qgrid/_version.py +++ b/qgrid/_version.py @@ -1,4 +1,4 @@ -version_info = (1, 0, 3, 'final') +version_info = (1, 0, 5, 'final') _specifier_ = {'alpha': 'a', 'beta': 'b', 'candidate': 'rc', 'final': ''} diff --git a/qgrid/grid.py b/qgrid/grid.py index 2b73ed9a..94802fce 100644 --- a/qgrid/grid.py +++ b/qgrid/grid.py @@ -464,8 +464,8 @@ class QgridWidget(widgets.DOMWidget): _model_name = Unicode('QgridModel').tag(sync=True) _view_module = Unicode('qgrid').tag(sync=True) _model_module = Unicode('qgrid').tag(sync=True) - _view_module_version = Unicode('1.0.3').tag(sync=True) - _model_module_version = Unicode('1.0.3').tag(sync=True) + _view_module_version = Unicode('1.0.5').tag(sync=True) + _model_module_version = Unicode('1.0.5').tag(sync=True) _df = Instance(pd.DataFrame) _df_json = Unicode('', sync=True) @@ -1220,8 +1220,9 @@ def _handle_qgrid_msg_helper(self, content): if col_info['type'] == 'datetime': val_to_set = pd.to_datetime(val_to_set) - old_value = self._df.at[location] - self._df.at[location] = val_to_set + old_value = self._df.loc[location] + self._df.loc[location] = val_to_set + query = self._unfiltered_df[self._index_col_name] == \ content['unfiltered_index'] self._unfiltered_df.loc[query, content['column']] = val_to_set diff --git a/qgrid/tests/test_grid.py b/qgrid/tests/test_grid.py index c6d671b8..cd4b1513 100644 --- a/qgrid/tests/test_grid.py +++ b/qgrid/tests/test_grid.py @@ -74,6 +74,20 @@ def test_edit_date(): "2013-01-16T00:00:00.000Z") +def test_edit_multi_index_df(): + df_multi = create_multi_index_df() + view = QgridWidget(df=df_multi) + old_val = df_multi.loc[('bar', 'two'), 1] + + check_edit_success(view, + 1, + 1, + old_val, + round(old_val, pd.get_option('display.precision') - 1), + 3.45678, + 3.45678) + + def check_edit_success(widget, col_name, row_index, @@ -85,7 +99,7 @@ def check_edit_success(widget, event_history = init_event_history('cell_edited', widget) grid_data = json.loads(widget._df_json)['data'] - assert grid_data[row_index][col_name] == old_val_json + assert grid_data[row_index][str(col_name)] == old_val_json widget._handle_qgrid_msg_helper({ 'column': col_name, @@ -95,9 +109,10 @@ def check_edit_success(widget, 'value': new_val_json }) + expected_index_val = widget._df.index[row_index] assert event_history == [{ 'name': 'cell_edited', - 'index': row_index, + 'index': expected_index_val, 'column': col_name, 'old': old_val_obj, 'new': new_val_obj @@ -107,7 +122,7 @@ def check_edit_success(widget, # call _update_table so the widget updates _df_json widget._update_table(fire_data_change_event=False) grid_data = json.loads(widget._df_json)['data'] - assert grid_data[row_index][col_name] == new_val_json + assert grid_data[row_index][str(col_name)] == new_val_json def test_edit_number():