Holoviews - store table edits for selected group

300 Views Asked by At

I am very interested in being able to tag data interactively. I have large datasets with many identifiers and want to display one by one and then give a tag regarding quality. A similar use case would be relevant where I want to select parts of the data for a give identifier in a holoviews plot and assign a label that could later be used in machine learning.

Below is a simplified case. I have a dataframe that may be split into groups by an id 'id'. For each unique 'id' I would like to show the data and assign a quality 'qual' that could be stored with the data or in another data table having the 'id' and the 'qual'. I have come some way into the following:

  • able to have a panel select box to select the subset of the dataframe
  • able to make an editable holoviews table
  • able to have a drop down select for quality

I am not able to

  • entirely link the id_select widget to the holoviews table.
  • store edits in editable table
  • make the qual_widget edit the holoviews table or store any selections in the qual_widget.

I have been thinking of different ways. Have tried panel functions using pn.depends depending on another function, but do not know how to fetch the changes into a data structure.

Pupose:

  • Beeing able to store edits in a holoviews editable table
  • Properly store assigned quality

Code

import holoviews as hv
import param
from holoviews import streams
from holoviews import opts
from holoviews.plotting.links import DataLink
hv.extension('bokeh', logo=None)
import numpy as np
import panel as pn

# data
ids = ['a']*3 +['b']*2 + ['c']*6
xs = np.linspace(0, 10, 11)
ys = np.sin(xs)
qs = ['Good']*2 + ['Poor']*9

# define holoviews table
table = hv.Table((ids, xs, ys,qs),'id',['x', 'y','qual']).opts(editable=True)

# list of unique ids

ids_unique = sorted(set(ids))

define dropdown widgets and put together panel app

id_widget = pn.widgets.Select(options=ids_unique, value=ids[0], name='select groupby id')
qual_widget = pn.widgets.Select(options=sorted(set(qs)), value='', name='define quality to be stored')

def sel_table(table, select_id):
    return table.select(id=select_id)

my_panel = pn.Row(sel_table(table, id_widget.value), pn.Column(id_widget, qual_widget))

my_panel 

I would be happy if it was possible to:

  • link all elements of my_panel above
  • store the edits in the holoviews table directly
  • have the qual_widget store it’s edit for each selected group by 'id'
0

There are 0 best solutions below