LongMatrices#

class caf.mat.matrices.LongMatrices(segmentation_, zoning, type_, *, data=None, name='LongMatrix', columns=None)[source]#

Bases: MatricesBase

Store multiple matrices in a single long DataFrame.

Intended only for use with smaller matrices or segmentations. Allows for multiple columns of data for the matrices.

Parameters:
  • segmentation – Segmentation for the matrices.

  • zoning (ZoningSystem) – ZoningSystem for all the matrices.

  • type – Type of the matrices.

  • data (DataFrame | None) – Optional data for all matrices in a single DataFrame, requires index (or columns) defining the segmentation and origin / destination zones.

  • name (str) – Optional name for matrices, default “LongMatrix”

  • columns (list[str] | None) – Optional list of data columns, if not given all columns not required for the index are used.

  • todo:: (..) – Override the aggregate and disaggregate methods in this class using DataFrame.groupby.

  • segmentation_ (Segmentation)

  • type_ (MatrixType)

Attributes

name

Name of the matrices.

Methods

__init__(segmentation_, zoning, type_, *[, ...])

exists()

Check if matrices exist for all slices.

from_csv(segmentation_, zoning, type_, path, *)

Load matrices from a single CSV.

get_matrix(slice_)

Load the data for a single matrix.

new(name, *[, segmentation_, zoning, type_])

Create a new instance of the matrices class with a new name.

save_csv(path)

Save matrices to a single CSV.

set_matrix(matrix, slice_)

Save the data for a single matrix.

to_frame([deep])

Return a copy of the underlying DataFrame.

Attributes Documentation

name#