romcomma.user.results.Collect§
- class Collect(csvs=None, folders=None, ignore_missing=False, **kwargs)[source]§
Bases:
object
A device for collecting – i.e. concatenating – csv files across folders or folds.
- Parameters:
csvs (Dict[str, Dict[str, Any]]) –
folders (Dict[str, Dict[str, Any]]) –
ignore_missing (bool) –
kwargs (Any) –
- __init__(csvs=None, folders=None, ignore_missing=False, **kwargs)[source]§
Construct a Collect object.
- Parameters:
csvs (Dict[str, Dict[str, Any]] | None) – Key = csv name (minus extension). Value = a Dict of options (kwargs) passed to
pd.read_csv
.folders (Dict[str, Dict[str, Any]] | None) – Key = folder containing csvs. Value = An (ordered) Dict of {Column name: Column value} to insert from R to L.
ignore_missing (bool) – Whether to raise an exception when a csv is missing from a folder.
**kwargs (Any) – kwargs passed straight to
pd.to_csv
.
Methods
__init__
([csvs, folders, ignore_missing])Construct a Collect object.
from_folders
(dst[, is_existing_deleted])Collect
dst/[self.csvs]
fromself.folders
.from_folds
(dst[, is_existing_deleted])Collect
dst/[self.folders]
fromFold(dst, [k])/[self.folders]
fork in self.Folds
.Attributes
Key = csv name (minus extension).
Column value} to insert from R to L.
Whether to raise an exception when a csv is missing from a folder.
kwargs passed straight to
pd.to_csv
.- write_options: Dict[str, Any] = {'float_format': '%.6f', 'index': False}§
kwargs passed straight to
pd.to_csv
.
- from_folders(dst, is_existing_deleted=False, **kwargs)[source]§
Collect
dst/[self.csvs]
fromself.folders
.- Parameters:
dst (Path | str) – The destination folder, to house
[self.csvs]
.is_existing_deleted – Whether to delete and recreate an existing
dst
.**kwargs (Any) – Write options passed straight to
pd.to_csv
.
- Return type:
Returns: ``self’’ for chaining calls.
- from_folds(dst, is_existing_deleted=False, **kwargs)[source]§
Collect
dst/[self.folders]
fromFold(dst, [k])/[self.folders]
fork in self.Folds
.- Parameters:
dst (Repository) – The destination folder, to house
[self.folders]
.is_existing_deleted – Whether to delete and recreate an existing
dst
.**kwargs (Any) – Write options passed straight to
pd.to_csv
.
- Return type:
Returns: ``self’’ for chaining calls.
- csvs: Dict[str, Dict[str, Any]] = {}§
Key = csv name (minus extension). Value = a Dict of options (kwargs) passed to
pd.read_csv
.
- folders: Dict[str, Dict[str, Any]] = {}§
Column value} to insert from R to L.
- Type:
Key = folder containing csvs. Value = An (ordered) Dict of {Column name
- ignore_missing: bool = False§
Whether to raise an exception when a csv is missing from a folder.