Weird behaviour of DataFrame.select{ed,ion}

I don’t understand how the selected rows in (release 0.7.0) Panel’s DataFrame widget interact with Python. Taking the DataFrame documentation as a basis and running it in a Jupyter notebook

table.selection = [0, 2]

correctly highlights the corresponding rows in the widget, which can then be extracted with table.selected_dataframe. So far, so good. But:

  1. If I click on another row, it gets highlighted, but table.selection does not change.
  2. Consequently, attaching a watcher to table.selection achieves nothing.
  3. I found out that table.selected acutally contains a list of the rows I select with the mouse. This is the behaviour I expected from table.selection.
  4. After selecting some lines, table.selected_dataframe still extracts the rows from table.selection, not from table.selected
  5. I cannot attach a watcher to table.selected, because then I get:
ValueError: selected parameter was not found in list of parameters of class DataFrame

Is this the intended behaviour? If so, could someone please explain it to me? All I want to do is show a non-editable DataFrame with a checkbox column, where the checkbox toggles if the user clicks on the corresponding row (and I see this change in Python). I should mention that I did play around a little with Bokeh’s CheckboxEditor, but didn’t get it to work properly (even if it did work as intended, I think you would have to click three times on a row to toggle the box: select, switch on edit mode, toggle checkbox).

Any help is greatly appreciated!
Thanks,
Martin

Hi Martin, the parameter was buggy in the 0.7 release due to a typo and has been fixed on master. I’ll be releasing 0.8 today with the fix.

Hi @marfel
Did you succeed in selecting rows using check boxes from a dataframe. Could you please help me out to do so. Currently once I select my rows by selecting checkboxes, and trying to extract I am getting error “checkbox is not json serializable”.

Some code snippet for checkboxes will be help, please

Hi biswajith,
I eventually discarded the notion of checkboxes and used the build-in row selection capabilities of df_widget = pn.widgets.DataFrame(mydf, disabled=True), which now seem to work properly. I.e. you can select one or several rows with the mouse and/or keyboard, which will then get highlighted. To get the selected part of the DataFrame use df_widget.selected_dataframe (or df_widget.selection for the 0-based index).