read_csv_matrix#

caf.toolkit.io.read_csv_matrix(path, format_=None, **kwargs)[source]#

Read matrix CSV in the square or long format.

Sorts the index and column names and makes sure they’re the same, doesn’t infill any NaNs created when reindexing.

Parameters:
  • path (Path) – Path to CSV file

  • format (str, optional) – Expected format of the matrix ‘square’ or ‘long’, if not given attempts to figure out the format by reading the top few lines of the file.

  • kwargs (keyword arguments) – Additional keyword arguments passed to read_csv.

  • format_ (Literal['square', 'long'] | None)

Returns:

Matrix file in square format with sorted columns and indices

Return type:

pd.DataFrame

Raises:

ValueError – If the format_ cannot be determined by reading the file or an invalid format_ is given.