diive.load_parquet

diive.load_parquet(filepath, output_middle_timestamp=True, sanitize_timestamp=True)[source]

Load data from Parquet file to pandas DataFrame.

Automatically detects time resolution and optionally converts timestamp representation. Index name and data types are preserved from the Parquet file.

Parameters:
  • filepath (str) – str or Path Path to Parquet file.

  • output_middle_timestamp (bool) – bool, optional (default True) Convert timestamp index to middle-of-period representation. Use when converting from ‘TIMESTAMP_END’ or ‘TIMESTAMP_START’ formats. Requires: sanitize_timestamp=True AND index name must be one of ‘TIMESTAMP_END’, ‘TIMESTAMP_START’, or ‘TIMESTAMP_MIDDLE’.

  • sanitize_timestamp (bool) – bool, optional (default True) Validate and regularize timestamp index: check naming convention, auto-detect frequency, remove duplicate timestamps and insert missing timestamps as empty (NaN) rows. Calls TimestampSanitizer. Records that are not on the regular time grid (for example 1-min records in 10-min data, or a record 1 s late) are removed, with a warning that gives their number. Use sanitize_timestamp=False to load all records as saved. Required for output_middle_timestamp to work.

Return type:

DataFrame

Returns:

pandas.DataFrame

Data with validated DatetimeIndex. Frequency is detected and stored.

Raises:
  • ValueError – If output_middle_timestamp=True but sanitize_timestamp=False.

  • ValueError – If index name is not recognized (see sanitize_timestamp parameter).

Notes

Parquet preserves index names, so ensure data was saved with proper naming (e.g., ‘TIMESTAMP_END’ for end-of-period data) before using output_middle_timestamp=True.

Example

See examples/io/io_load_save_parquet.py