fastplotlib.widgets.nd_widget.extras.pandas.PandasSlicer#

class PandasSlicer(data, dims, display_dims, columns, tooltip_columns=None, **kwargs)[source]#

NDPositionsSlicer subclass that reads positional data from the columns of a pandas.DataFrame instead of an n-dimensional array.

Each entry in columns names the columns that hold the coordinates of one graphic, so the number of entries is the number of graphics in the collection and the number of rows is the size of the p dim. There are no additional slider dims, p is the only one.

Available as fpl.nds_extras.pandas.PandasSlicer, pass it as the slicer to NDWSubplot.add_nd_lines(), add_nd_scatter() or add_nd_timeseries().

Parameters:
  • data (pd.DataFrame) – DataFrame holding the coordinates, one column per coordinate of each graphic.

  • dims (tuple[str, str, str]) – Names for the 3 dims. A DataFrame has no further dims to name, so these are the same 3 names as display_dims.

  • display_dims (tuple[str, str, str]) – The 3 spatial dims in display order: (n_graphics, p, <value dim>).

  • columns (list[tuple[str, str] | tuple[str, str, str]]) – One entry per graphic, each a tuple of 2 or 3 column names giving the (x, y) or (x, y, z) coordinates of that graphic. Ex: [("nose_x", "nose_y"), ("tail_x", "tail_y")] for two keypoint trajectories.

  • tooltip_columns (list[str], optional) – One column name per graphic. The value of that column at the hovered datapoint is shown in the tooltip, ex: a per-keypoint likelihood column. Must be the same length as columns.

  • kwargs – passed to NDPositionsSlicer, i.e. display_window, max_display_datapoints, slider_dim_transforms, datapoints_window_func and spatial_func.