mcbrowse.common.reorders¶
Allow sorting data.
In principle, the order of graph data does not matter. In practice, the implementation(s) will plot graphical elements in order, so this will control the order of entries in a bar chart, or, for scatter plots, later data will overwrite earlier data. It is therefore sometimes useful to reorder the data before giving it to the plot function.
Todo
Add functions for clustering and/or ordering 2D data for heatmaps into the reorders module.
- mcbrowse.common.reorders.tidy_sort_by(frame: Union[FrameInRows, FrameInColumns], order: Union[Callable[[Series], Any], Sequence[str]]) Union[FrameInRows, FrameInColumns][source]¶
Sort the tidy
framerows using theorder.If the order is a function, we apply it to each frame row and sort the frame by the resulting keys.
Otherwise, the order is a sequence of
<nameor>namelisting the columns to sort by in ascending or descending order.
- mcbrowse.common.reorders.tidy_randomize(frame: Union[FrameInRows, FrameInColumns], *, random_seed: Optional[int] = None) Union[FrameInRows, FrameInColumns][source]¶
Randomize the order of the tidy
framerows.If the
random_seedisNone, then then the result will not be reproducible.Note
Randomization is a quick way to ensure all data subsets get a fair chance to be “on top”, based on their size.