Quantum Dataset Exports API
Quantum Dataset Exports
- graphcalc.quantum.dataset_exports.quantum_package_to_dataframe(package: Mapping[str, Any]) DataFrame[source]
Convert a quantum dataset package into a pandas DataFrame.
- Parameters:
package (mapping) – Dataset package expected to contain a
"rows"entry.- Returns:
DataFrame built from
package["rows"].- Return type:
pandas.DataFrame
- Raises:
ValueError – If the package does not contain a
"rows"key.
- graphcalc.quantum.dataset_exports.quantum_rows_to_dataframe(rows: Sequence[Mapping[str, Any]]) DataFrame[source]
Convert a sequence of dataset rows into a pandas DataFrame.
- Parameters:
rows (sequence of mappings) – Row dictionaries, typically produced by a quantum dataset generator.
- Returns:
DataFrame containing the supplied rows.
- Return type:
pandas.DataFrame
Notes
This function preserves the row dictionaries as-is, allowing tuple-valued columns such as subsystem patterns or measurement-probability tuples to remain available in the resulting DataFrame.
- graphcalc.quantum.dataset_exports.save_quantum_column_definitions_json(package: Mapping[str, Any], path: str | Path, *, indent: int = 2, sort_keys: bool = True) Path[source]
Save the column-definition dictionary of a quantum dataset package as JSON.
- Parameters:
package (mapping) – Dataset package expected to contain a
"column_definitions"entry.path (str or pathlib.Path) – Output JSON path.
indent (int, default=2) – JSON indentation level.
sort_keys (bool, default=True) – Whether to sort keys in the output JSON.
- Returns:
The resolved output path.
- Return type:
pathlib.Path
- Raises:
ValueError – If the package does not contain a
"column_definitions"key.
- graphcalc.quantum.dataset_exports.save_quantum_metadata_json(package: Mapping[str, Any], path: str | Path, *, indent: int = 2, sort_keys: bool = True) Path[source]
Save the metadata dictionary of a quantum dataset package as JSON.
- Parameters:
package (mapping) – Dataset package expected to contain a
"metadata"entry.path (str or pathlib.Path) – Output JSON path.
indent (int, default=2) – JSON indentation level.
sort_keys (bool, default=True) – Whether to sort keys in the output JSON.
- Returns:
The resolved output path.
- Return type:
pathlib.Path
- Raises:
ValueError – If the package does not contain a
"metadata"key.
- graphcalc.quantum.dataset_exports.save_quantum_package_csv(package: Mapping[str, Any], path: str | Path, *, index: bool = False) Path[source]
Save the rows of a quantum dataset package as a CSV file.
- Parameters:
package (mapping) – Dataset package expected to contain a
"rows"entry.path (str or pathlib.Path) – Output CSV path.
index (bool, default=False) – Whether to write the DataFrame index to the CSV file.
- Returns:
The resolved output path.
- Return type:
pathlib.Path
Notes
Non-scalar objects such as tuples and dictionaries are serialized by pandas using their standard string representations in the CSV output.