create_cuts
Functions to create tables by cutting the data based on unique values in specified columns.
Functions:
Name | Description |
---|---|
create_table_cuts |
Create a collection of tables based on the unique values in the cut_columns. |
create_regional_rag_summary_tables_cuts |
Create a collection of Regional RAG summary tables by cutting the pivoted master data by the
NHS England Region, |
create_table_cuts(data, cut_columns, drop_cut_columns=False)
Create a collection of tables based on the unique values in the cut_columns. The function creates a table for each unique value in the cut_columns and separates the data into a dictionary with the unique values (or combinations of unique values) as the keys.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
DataFrame
|
The data to cut |
required |
cut_columns
|
list or str
|
The column(s) to cut the data by |
required |
drop_cut_columns
|
bool
|
Whether to drop the cut columns from the DataFrame, by default False |
False
|
Returns:
Type | Description |
---|---|
dict
|
A dictionary of DataFrames with the unique values in the cut_columns as the keys |
Raises:
Type | Description |
---|---|
ColumnsNotFoundError
|
If the cut_columns specified are not found in the dataset |
Source code in devices_rap/create_cuts.py
create_regional_table_cuts(tables)
Create a collection of Regional RAG summary tables by cutting the provided tables by the 'Region' column.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tables
|
dict
|
A dictionary where keys are table types (e.g., 'summary', 'detailed') and values are the corresponding DataFrames. |
required |
Returns:
Type | Description |
---|---|
dict
|
A dictionary where keys are regions and values are dictionaries of table types and their corresponding filtered DataFrames. |