Breakdown
The Breakdown class is used to conditionally aggregate data from a Table instance. It enables users to construct 1D and 2D DataFrames that can then be used in reporting or as desired.
- class chromaquant.data.breakdown.Breakdown(start_cell: str = '', sheet: str = '', conditional_aggregate: str = 'SUMIFS', header: str = '', results: Results = None)
Class used to conditionally aggregate data from a Table
Parameters
- start_cellstr, optional
Reference to cell in Excel where data will be reported, referring to the top-left of report range. Must be a valid Excel cell (e.g., ‘A1’, ‘$B$2’).
- sheetstr, optional
Name of Excel worksheet (sheet within workbook) where data will be reported.
- conditional_aggregate: str, optional
String representation of the desired conditional aggregate formula. Options area ‘SUMIFS’, ‘COUNTIFS’, ‘AVERAGEIFS’, ‘MINIFS’, and ‘MAXIFS’. Default is ‘SUMIFS’.
- header: str, optional
Header to add above a dataset, equivalent to a title.
- results: Results, optional
Results object that mediates this DataSet.
Raises
- ValueError
If a conditional_aggregate is passed that is not a valid option.
- ValueError
If sheet is set to a blank string.
- ValueError
If start_cell is set to an invalid Excel cell.
- ValueError
If no summarize_column is provided for conditional aggregates besides COUNTIFS when creating a conditional aggregate formula.
- ValueError
If more than two key-value pairs are in groups_to_summarize or a key does not match a passed group by column when creating a 2D breakdown.
- create_1D(table: Table, group_by_column: str, summarize_column: str, groups_to_summarize: list[str] = None)
Method to create a one-dimensional breakdown.
Parameters
- tableTable
An instance of Table.
- group_by_columnstr
The name of the column by which to aggregate results.
- summarize_columnstr
The name of the column to summarize.
- groups_to_summarizelist[str], optional
An optional list of groups to include in the breakdown, overwriting the default list created that includes all groups present in the current Table, by default None.
Returns
None
- create_2D(table: Table, group_by_col_1: str, group_by_col_2: str, summarize_column: str, groups_to_summarize: dict[str, list[str]] = None)
Method to create a two-dimensional breakdown.
Parameters
- tableTable
An instance of Table.
- group_by_col_1str
The name of the first column by which to aggregate results.
- group_by_col_2str
The name of the second column by which to aggregate results.
- summarize_columnstr
The name of the column to summarize.
- groups_to_summarizedict[str, list[str]], optional
An optional dictionary of groups to include in the breakdown. The key in each pair is the name of a passed group-by column and the value is a list of groups to include in the breakdown. This overwrites the default list created that includes all groups present in the current Table under the passed group-by columns, by default None.
Returns
- ValueError
If more than two key-value pairs are in groups_to_summarize or a key does not match a passed group by column when creating a 2D breakdown.
- property data: Any
Get, set, or delete data stored in the DataSet. Common types include str, bool, int, float, list, dict, or pandas DataFrame.
- property sheet: str
Get, set, or delete the name of the Excel worksheet to report to.
- property start_cell: str
Get, set, or delete the Excel reference where data will be reported.