BaseLoader
Bases: BaseConfig, ABC
Abstract base class for loading and saving processed data.
This class provides a structure for loading and saving datasets and defines abstract methods that need to be implemented by subclasses. It includes methods for specifying data paths and filenames for loading and saving operations.
Inherits
BaseConfig: Provides configuration settings for data processing.ABC: Specifies abstract methods for subclasses to implement.
Abstract Methods
load_data: Load processed data from the specified path and file.save_data: Save processed data to the specified path and file.
Example
loader = SomeConcreteLoader()
data = loader.load_data(path=Path("/data"), name="processed_data.csv")
loader.save_data(data=data, path=Path("/data"), name="saved_data.csv")
Source code in periomod/data/_basedata.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
__init__()
¶
Initializes the BaseLoader, defining the load_data abstract method.
Source code in periomod/data/_basedata.py
35 36 37 | |
load_data(path)
abstractmethod
¶
Loads the processed data from the specified path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Directory path for the processed data. |
required |
Source code in periomod/data/_basedata.py
39 40 41 42 43 44 45 | |
save_data(data, path)
abstractmethod
¶
Saves the processed data to the specified path as a CSV file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
The processed DataFrame. |
required |
path
|
Union[str, Path]
|
Path (including filename) where data will be saved. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the DataFrame is empty. |
Source code in periomod/data/_basedata.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |