wide_matrix_internal_external_report#
- caf.toolkit.pandas_utils.wide_matrix_internal_external_report(df, int_select, ext_select)[source]#
Generate a matrix report of value totals internal and externally.
Generates a 3x3 Pandas DataFrame detailing the total of values across 4 categories: internal-internal, internal-external, external-internal, external-external. Row and columns totals are also presented.
- Parameters:
df (DataFrame) – The dataframe to generate the report.
int_select (Collection[Any]) – A list of the column and index identifiers to mark as “internal”.
ext_select (Collection[Any]) – A list of the column and index identifiers to mark as “external”.
- Returns:
A report of internal and external demand in df.
- Return type:
report
- Warns:
UserWarning – If internal_selection and external_selection do not contain all the values listed in df, OR they have overlapping values - leading to double counting.
Examples
>>> df = pd.DataFrame(np.arange(25).reshape(5, 5)) >>> df 0 1 2 3 4 0 0 1 2 3 4 1 5 6 7 8 9 2 10 11 12 13 14 3 15 16 17 18 19 4 20 21 22 23 24
>>> wide_matrix_internal_external_report(df,[0, 1, 2],[3, 4]) internal external total internal 54.0 51.0 105.0 external 111.0 84.0 195.0 total 165.0 135.0 300.0