romcomma.base.classes.Frame§

class Frame(csv, data=None, index=None, columns=None, dtype=None, copy=None, **kwargs)[source]§

Bases: object

Encapsulates a pandas DataFrame backed by a source file.

Parameters:
  • csv (Path) –

  • data (pd.DataFrame | NP.Array | Iterable | Dict) –

  • index (pd.Index | NP.ArrayLike) –

  • columns (pd.Index | NP.ArrayLike) –

  • dtype (np.dtype | None) –

  • copy (bool | None) –

__init__(csv, data=None, index=None, columns=None, dtype=None, copy=None, **kwargs)[source]§

Construct a Frame, from csv or pd.DataFrame. If data is None, the Frame is read from csv. Otherwise the Frame is written to csv.

Parameters:
  • csv (Path | str) – The csv file path, without .csv.

  • data (DataFrame | ndarray | Iterable | Dict | None) – The data to store. If None, a pd.DataFrame is read from csv. See pd.DataFrame.

  • index (Index | int | float | Sequence[int | float] | ndarray | Sequence[int | float | Sequence[int | float] | ndarray] | Sequence[int | float | Sequence[int | float] | ndarray | Sequence[int | float | Sequence[int | float] | ndarray]] | Sequence[Sequence[int | float | Sequence[int | float] | ndarray | Sequence[int | float | Sequence[int | float] | ndarray]]] | None) –

    See pd.DataFrame.

  • columns (Index | int | float | Sequence[int | float] | ndarray | Sequence[int | float | Sequence[int | float] | ndarray] | Sequence[int | float | Sequence[int | float] | ndarray | Sequence[int | float | Sequence[int | float] | ndarray]] | Sequence[Sequence[int | float | Sequence[int | float] | ndarray | Sequence[int | float | Sequence[int | float] | ndarray]]] | None) –

    See pd.DataFrame.

  • dtype (dtype | None) –

    See pd.DataFrame.

  • copy (bool | None) –

    See pd.DataFrame.

  • **kwargs – Passed straight to pd.read_csv or DataFrame.to_csv.

Methods

__init__(csv[, data, index, columns, dtype, ...])

Construct a Frame, from csv or pd.DataFrame.

broadcast_value(target_shape[, is_diagonal])

Broadcast a frame

write(**kwargs)

Write to csv.

Attributes

df

np

tf

csv

The csv file path, without .csv.

write(**kwargs)[source]§

Write to csv. This is called whenever the data in the Frame changes.

Parameters:

**kwargs (Any) – Options passed straight to self.to_csv().

Return type:

Frame

Returns: self, for call chaining.

broadcast_value(target_shape, is_diagonal=True)[source]§

Broadcast a frame

Parameters:
  • target_shape (Tuple[int, int]) – The shape to broadcast to.

  • is_diagonal (bool) – Whether to zero the off-diagonal elements of a square matrix.

Return type:

Frame

Returns: Self, for chaining calls. :raises IndexError: If broadcasting is impossible.

csv: Path§

The csv file path, without .csv.