Open maximlt opened 4 months ago
I'd suggest we add the row index
to the events to distinguish and then improve the documentation to be very clear that the .selection
and the event row
values are integer indexes into the original data.
Also let's make sure we add nicer docstrings to the CellClickEvent
and TableEditEvent
.
The Tabulator widget has a few attributes and events that refer to particular rows of the dataframe:
selection
: parameter list value updated when the selection changesClickEvent
: event registered withon_click
and fired on a cell clickTableEditEevent
: event registered withon_edit
and fired on a cell editThe two events, via their
row
attribute, andselection
, indicate the integer-location of the row(s) relative to the original dataframe, i.ewidget.value
.Users have reported sometimes being confused by the semantics of the returned row value (e.g. https://github.com/holoviz/panel/issues/6997):
df.loc
) or integer-position (df.iloc
)?I would also like to report a small UX issue with the events in particular, which return
row
andcolumn
that often leads me to incorrectly usedf.loc[event.row, event.column]
when I want to get a handle on the complete row.df.loc
will only work if the dataframe has the default Pandas index, otherwise, it will error or, worse, return the wrong row (e.g. with a dataframe that's already be filtered in a preprocessing step). The right call to make isdf.loc[df.index.get_loc(event.row), event.column]
, or alternativelydf.iloc[event.row, df.columns.get_loc(event.column)]
.