Skip to content

Commit 42ed3db

Browse files
authored
Merge pull request #199 from quantopian/fix-edit-unnamed-index
Fixing issue with editing a table with unnamed index columns, bumping version again
2 parents 2fd7f48 + 60c7df3 commit 42ed3db

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed

js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "qgrid",
3-
"version": "1.0.3",
3+
"version": "1.0.5",
44
"description": "An Interactive Grid for Sorting and Filtering DataFrames in Jupyter Notebook",
55
"author": "Quantopian Inc.",
66
"main": "src/index.js",

js/src/qgrid.widget.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class QgridModel extends widgets.DOMWidgetModel {
3636
_view_name : 'QgridView',
3737
_model_module : 'qgrid',
3838
_view_module : 'qgrid',
39-
_model_module_version : '^1.0.3',
40-
_view_module_version : '^1.0.3',
39+
_model_module_version : '^1.0.5',
40+
_view_module_version : '^1.0.5',
4141
_df_json: '',
4242
_columns: {}
4343
});

qgrid/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version_info = (1, 0, 3, 'final')
1+
version_info = (1, 0, 5, 'final')
22

33
_specifier_ = {'alpha': 'a', 'beta': 'b', 'candidate': 'rc', 'final': ''}
44

qgrid/grid.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,8 @@ class QgridWidget(widgets.DOMWidget):
464464
_model_name = Unicode('QgridModel').tag(sync=True)
465465
_view_module = Unicode('qgrid').tag(sync=True)
466466
_model_module = Unicode('qgrid').tag(sync=True)
467-
_view_module_version = Unicode('1.0.3').tag(sync=True)
468-
_model_module_version = Unicode('1.0.3').tag(sync=True)
467+
_view_module_version = Unicode('1.0.5').tag(sync=True)
468+
_model_module_version = Unicode('1.0.5').tag(sync=True)
469469

470470
_df = Instance(pd.DataFrame)
471471
_df_json = Unicode('', sync=True)
@@ -1220,8 +1220,9 @@ def _handle_qgrid_msg_helper(self, content):
12201220
if col_info['type'] == 'datetime':
12211221
val_to_set = pd.to_datetime(val_to_set)
12221222

1223-
old_value = self._df.at[location]
1224-
self._df.at[location] = val_to_set
1223+
old_value = self._df.loc[location]
1224+
self._df.loc[location] = val_to_set
1225+
12251226
query = self._unfiltered_df[self._index_col_name] == \
12261227
content['unfiltered_index']
12271228
self._unfiltered_df.loc[query, content['column']] = val_to_set

qgrid/tests/test_grid.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,20 @@ def test_edit_date():
7474
"2013-01-16T00:00:00.000Z")
7575

7676

77+
def test_edit_multi_index_df():
78+
df_multi = create_multi_index_df()
79+
view = QgridWidget(df=df_multi)
80+
old_val = df_multi.loc[('bar', 'two'), 1]
81+
82+
check_edit_success(view,
83+
1,
84+
1,
85+
old_val,
86+
round(old_val, pd.get_option('display.precision') - 1),
87+
3.45678,
88+
3.45678)
89+
90+
7791
def check_edit_success(widget,
7892
col_name,
7993
row_index,
@@ -85,7 +99,7 @@ def check_edit_success(widget,
8599
event_history = init_event_history('cell_edited', widget)
86100

87101
grid_data = json.loads(widget._df_json)['data']
88-
assert grid_data[row_index][col_name] == old_val_json
102+
assert grid_data[row_index][str(col_name)] == old_val_json
89103

90104
widget._handle_qgrid_msg_helper({
91105
'column': col_name,
@@ -95,9 +109,10 @@ def check_edit_success(widget,
95109
'value': new_val_json
96110
})
97111

112+
expected_index_val = widget._df.index[row_index]
98113
assert event_history == [{
99114
'name': 'cell_edited',
100-
'index': row_index,
115+
'index': expected_index_val,
101116
'column': col_name,
102117
'old': old_val_obj,
103118
'new': new_val_obj
@@ -107,7 +122,7 @@ def check_edit_success(widget,
107122
# call _update_table so the widget updates _df_json
108123
widget._update_table(fire_data_change_event=False)
109124
grid_data = json.loads(widget._df_json)['data']
110-
assert grid_data[row_index][col_name] == new_val_json
125+
assert grid_data[row_index][str(col_name)] == new_val_json
111126

112127

113128
def test_edit_number():

0 commit comments

Comments
 (0)