read_draws

params.read_draws(source, *, iteration=None)

Validate an external parameter sample as a draw matrix.

Reads a CSV path or takes a DataFrame. If iteration names a column, it becomes the index; otherwise a fresh RangeIndex named "iteration" is assigned. Every remaining column must be numeric, so the matrix can flow through the run loop unchanged.

Parameters

Name Type Description Default
source pd.DataFrame | str | Path A draw matrix DataFrame, or a path to a CSV file of one. required
iteration str | None Name of the column holding the iteration index. None assigns a fresh RangeIndex. None

Returns

Name Type Description
pd.DataFrame DataFrame with an index named "iteration" and one numeric column per
pd.DataFrame parameter.

Raises

Name Type Description
ValueError If the table is empty, iteration names a missing column, or any parameter column is non-numeric.

Example

import pandas as pd from heormodel.params import read_draws df = pd.DataFrame({“p_die”: [0.1, 0.2], “cost”: [900.0, 1100.0]}) read_draws(df).index.name ‘iteration’