MatrixReport#

class caf.toolkit.pandas_utils.MatrixReport(matrix, *, translation_factors=None, translation_from_col=None, translation_to_col=None, translation_factors_col=None)[source]#

Creates a high level summary of a matrix and its trip ends.

Parameters:
  • matrix (pd.DataFrame) – The matrix to be summarised.

  • translation (Optional[pd.DataFrame], optional) – A translation matrix to be applied to the matrix,. If None no translations is applied, by default None.

  • translation_from_col (Optional[str], optional) – The column in the translation matrix to translate from, by default None.

  • translation_to_col (Optional[str], optional) – The column in the translation matrix to translate to, by default None.

  • translation_factors_col (Optional[str], optional) – The column in the translation matrix to use as factors, by default None.

  • translation_factors (Optional[pd.DataFrame])

Attributes

column_sum

The column sums of the matrix.

describe

High level statistics on the original and, if provided, sectorised matrix.

distribution

Distribution if trip_length_distribution has been called, otherwise none.

row_sum

The row sums of the matrix.

sector_matrix

Sector matrix if translation vector provided, otherwise none.

trip_ends

The row and column sums of the matrix.

vkms

Vehicle kms if calc_vehicle_kms has been called, otherwise none.

Methods

__init__(matrix, *[, translation_factors, ...])

calc_vehicle_kms(cost_matrix, *[, ...])

Calculate vehicle kms from the matrix passed on initialisation.

from_file(path, *[, translation_path, ...])

Create an instance of MatrixReport from file paths.

trip_length_distribution(cost_matrix, bins, *)

Calculate a distribution from the matrix passed on initialisation.

write_to_excel(writer[, label, ...])

Write the report to an Excel file.

Attributes Documentation

column_sum#

The column sums of the matrix.

describe#

High level statistics on the original and, if provided, sectorised matrix.

distribution#

Distribution if trip_length_distribution has been called, otherwise none.

row_sum#

The row sums of the matrix.

sector_matrix#

Sector matrix if translation vector provided, otherwise none.

trip_ends#

The row and column sums of the matrix.

vkms#

Vehicle kms if calc_vehicle_kms has been called, otherwise none.