module samples.sample_table_processor
¶
Read and write ZARP sample tables.
function read
¶
read(
path: Path,
index_col: Optional[int] = None,
mapping: Optional[Mapping] = None,
columns: Optional[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]] = None
) → DataFrame
Set records from sample table file.
Args:
path
: Sample table path.index_col
: Optional index column.columns
: Optional list of sample table columns to select. If not provided, all columns will be selected. Column selection will occur before column renaming.mapping
: Optional mapping of column names to rename columns.
Returns: Pandas DataFrame
object.
function write
¶
write(
df: DataFrame,
path: Path = PosixPath('/home/runner/work/zarp-cli/zarp-cli/sample_table.tsv'),
mapping: Optional[Mapping] = None,
columns: Optional[Sequence] = None
) → None
Write sample table.
Args:
df
: PandasDataFrame
object to write.path
: Path to write sample table to.mapping
: Optional mapping of column names to rename columns.columns
: Optional list of sample table columns to write. Columns will be written in the specified order. Missing columns will be created with empty strings. If not provided, all columns will be written. Column selection will occur after column renaming.