diive.to_diive_format

diive.to_diive_format(data, timestamp_name=None)[source]

Coerce a DataFrame to the diive parquet format.

Ensures the data follows the diive convention:

  • One header row: MultiIndex columns are flattened to their top level so there is a single level of column names.

  • Named timestamp index: the index name must be one of 'TIMESTAMP_END', 'TIMESTAMP_MIDDLE' or 'TIMESTAMP_START' (indicating what the timestamp marks). Pass timestamp_name to set it; otherwise the existing index name is validated.

Parameters:
  • data (DataFrame) – DataFrame to coerce.

  • timestamp_name (str) – Optional timestamp index name to set before validation. Must be one of ALLOWED_TIMESTAMP_NAMES.

Return type:

DataFrame

Returns:

A (possibly copied) DataFrame in diive format.

Raises:

ValueError – If no valid timestamp index name is available.