typeddfs.matrix_dfs

DataFrames that are essentially n-by-m matrices.

Module Contents

class typeddfs.matrix_dfs.AffinityMatrixDf(data=None, index=None, columns=None, dtype=None, copy=False)

A similarity or distance matrix. The rows and columns must match, and only 1 index is allowed.

__repr__() str

Return repr(self).

__str__() str

Return str(self).

classmethod _check(df: typeddfs.base_dfs.BaseDf)

Should raise an typeddfs.df_errors.InvalidDfError or subclass for issues.

classmethod get_typing() typeddfs.df_typing.DfTyping
classmethod new_df(n: Union[int, Sequence[str]] = 0, fill: Union[int, float, complex] = 0) __qualname__

Returns a DataFrame that is empty but valid.

Parameters
  • n – Either a number of rows/columns or a sequence of labels. If a number is given, will choose (str-type) labels β€˜0’, β€˜1’, …

  • fill – A value to fill in every cell. Should match self.required_dtype.

Raises
  • InvalidDfError – If a function in verifications fails (returns False or a string).

  • IntCastingNaNError – If fill is NaN or inf and self.required_dtype does not support it.

symmetrize() __qualname__

Averages with its transpose, forcing it to be symmetric.

class typeddfs.matrix_dfs.LongFormMatrixDf(data=None, index=None, columns=None, dtype=None, copy=False)

A long-form matrix with columns β€œrow”, β€œcolumn”, and β€œvalue”.

classmethod get_typing() typeddfs.df_typing.DfTyping
class typeddfs.matrix_dfs.MatrixDf(data=None, index=None, columns=None, dtype=None, copy=False)

A dataframe that is best thought of as a simple matrix. Contains a single index level and a list of columns, with numerical values of a single dtype.

classmethod get_typing() typeddfs.df_typing.DfTyping
classmethod new_df(rows: Union[int, Sequence[str]] = 0, cols: Union[int, Sequence[str]] = 0, fill: Union[int, float, complex] = 0) __qualname__

Returns a DataFrame that is empty but valid.

Parameters
  • rows – Either a number of rows or a sequence of labels. If a number is given, will choose (str-type) labels β€˜0’, β€˜1’, …

  • cols – Either a number of columns or a sequence of labels. If a number is given, will choose (str-type) labels β€˜0’, β€˜1’, …

  • fill – A value to fill in every cell. Should match self.required_dtype. String values are

Raises
  • InvalidDfError – If a function in verifications fails (returns False or a string).

  • IntCastingNaNError – If fill is NaN or inf and self.required_dtype does not support it.