I am trying to write a parameterized class that has a method, which can access the selected rows of a DataFrame widget. If I run the below code in a notebook and then access the DataFrame widget with table_view[1].selection
, then I get back the index of the selected row. Is there a way to access the selected indices from a method of the parametrized class?
As an alternative, a method that is able to watch the DataFrame widget for changes and then calculate new values for the table would also be helpful.
Thanks,
Ben
default_df = pd.DataFrame({'names': ['A', 'B'],
'v1': [20, 30],
'v2': [100, 200],
'v3': [480, 360]})
class ReactiveTable(param.Parameterized):
table = param.DataFrame(default=default_df)
v1 = param.Number()
v2 = param.Number()
v3 = param.Number()
@param.depends('table')
def update_params_with_selected_row_values(self):
# Is there a way to access pn.widgets.DataFrame.selection or selected_dataframe here?
pass
rt = ReactiveTable()
table_view = pn.Column(pn.Row(rt.param.v1, rt.param.v2, rt.param.v3), rt.param.table)
table_view