save: save and export tables into files
Code author: Ueli Sauter, Peter Kraus
The function dgpost.utils.save.save()
processes the below specification
in order to save the given DataFrame:
- pydantic model dgbowl_schemas.dgpost.recipe.Save
Save a table into an external (
pkl
,xlsx
) file.Show JSON schema
{ "title": "Save", "description": "Save a table into an external (``pkl``, ``xlsx``) file.", "type": "object", "properties": { "table": { "title": "Table", "type": "string" }, "as": { "title": "As", "type": "string" }, "type": { "anyOf": [ { "enum": [ "pkl", "json", "xlsx", "csv", "nc" ], "type": "string" }, { "type": "null" } ], "default": null, "title": "Type" }, "columns": { "anyOf": [ { "items": { "type": "string" }, "type": "array" }, { "type": "null" } ], "default": null, "title": "Columns" }, "sigma": { "default": true, "title": "Sigma", "type": "boolean" } }, "additionalProperties": false, "required": [ "table", "as" ] }
- Config:
extra: str = forbid
populate_by_name: bool = True
- field table: str [Required]
The name of the table loaded in memory to be stored.
- field as_: str [Required] (alias 'as')
Path to which the table is stored.
- field type: Literal['pkl', 'json', 'xlsx', 'csv', 'nc'] | None = None
Type of the output file.
- field columns: Sequence[str] | None = None
Columns to be exported. By default (
None
), all columns from the specifiedtable
will be exported.Note
If any of the columns supplied is not present in the table, a warning will be printed by
dgpost
.
- field sigma: bool = True
Whether uncertainties/error estimates in the data should be stripped. Particularly useful when exporting into
xlsx
orcsv
.
Note
Metadata, including the recipe used to create the saved file, as well as
provenance information about the version of dgpost used to process the
recipe are saved into the df.attrs["meta"]
entry and therefore only
available in pkl
or json
exports.
- dgpost.utils.save.save(table: DataFrame, path: str, type: str | None = None, columns: list[str] | None = None, sigma: bool = True, meta: dict | None = None) None