unravel.cluster_stats.sunburst_sort module#
Use cstats_sunburst_sort (sunburst_sort) from UNRAVEL to sort sunburst CSVs by hierarchy and value.
- Prereqs:
cstats_sunburst,cstats_index,cstats_summary, orabca_sunburst, etc. to generate sunburst CSVs.
- Inputs:
CSVs with sunburst data (the name should end with sunburst.csv)
- Outputs:
A hierarchically sorted CSV: _sorted_sunburst_CSVs/<input_file_name>_sunburst_sorted.csv
Sorting by hierarchy and value:#
- Group by Depth: Starting from the earliest depth column, for each depth level:
Sum the values of all rows sharing the same region (or combination of regions up to that depth).
Sort these groups by their aggregate value in descending order, ensuring larger groups are prioritized.
- Sort Within Groups: Within each group created in step 1:
Sort the rows by their individual value in descending order.
- Maintain Grouping Order:
As we move to deeper depth levels, maintain the grouping and ordering established in previous steps (only adjusting the order within groups based on the new depth’s aggregate values).
Usage:#
cstats_sunburst_sort [-i <input_files>] [-v]
- unravel.cluster_stats.sunburst_sort.sunburst_sort(df, value_column=None, depth_columns=None)[source]#
Sort a sunburst hierarchy while preserving parent-group contiguity.
- Rows are ordered so that:
top-level groups are ordered by summed value
within each parent group, child groups are ordered by summed value
leaf rows are ordered by individual value
For ragged hierarchies, missing depth values are temporarily filled across columns within each row for grouping, then restored from the original table before returning.