pandas_openscm.db.loading#
Loading of data from disk
Functions:
| Name | Description |
|---|---|
convert_db_index_to_metadata |
Convert a database index to metadata |
load_data |
Load data |
load_data_files |
Load a number of data files |
load_db_file_map |
Load database file map from file |
load_db_index |
Load database index from file |
load_db_metadata |
Load database metadata from file |
convert_db_index_to_metadata #
convert_db_index_to_metadata(
db_index: DataFrame,
) -> MultiIndex
Convert a database index to metadata
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db_index
|
DataFrame
|
Database index |
required |
Returns:
| Type | Description |
|---|---|
MultiIndex
|
Metadata |
Source code in src/pandas_openscm/db/loading.py
load_data #
load_data(
*,
backend_data: OpenSCMDBDataBackend,
db_index: DataFrame,
db_file_map: Series[Path],
db_dir: Path,
selector: Index[Any]
| MultiIndex
| Selector
| None = None,
out_columns_type: type | None = None,
out_columns_name: str | None = None,
parallel_op_config: ParallelOpConfig | None = None,
progress: bool = False,
max_workers: int | None = None,
) -> DataFrame
Load data
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend_data
|
OpenSCMDBDataBackend
|
Backend to use to load data from disk |
required |
db_index
|
DataFrame
|
Index of the database from which to load |
required |
db_file_map
|
Series[Path]
|
File map of the database from which to load |
required |
db_dir
|
Path
|
The directory in which the database lives |
required |
selector
|
Index[Any] | MultiIndex | Selector | None
|
Selector to use to choose the data to load |
None
|
out_columns_type
|
type | None
|
Type to set the output columns to. If not supplied, we don't set the output columns' type. |
None
|
out_columns_name
|
str | None
|
The name for the columns in the output. If not supplied, we don't set the output columns' name. This can also be set with pd.DataFrame.rename_axis but we provide it here for convenience (and in case you couldn't find this trick for ages, like us). |
None
|
parallel_op_config
|
ParallelOpConfig | None
|
Configuration for executing the operation in parallel with progress bars If not supplied, we use the values of |
None
|
progress
|
bool
|
Should progress bar(s) be used to display the progress of the deletion? Only used if |
False
|
max_workers
|
int | None
|
Maximum number of workers to use for parallel processing. If supplied, we create an instance of
concurrent.futures.ProcessPoolExecutor
with the provided number of workers.
A process pool seems to be the sensible default from our experimentation,
but it is not a universally better choice.
If you need something else because of how your database is set up,
simply pass If not supplied, the loading is executed serially. Only used if |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Loaded data |
Source code in src/pandas_openscm/db/loading.py
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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
load_data_files #
load_data_files(
*,
files_to_load: Iterable[Path],
backend_data: OpenSCMDBDataBackend,
parallel_op_config: ParallelOpConfig | None = None,
progress: bool = False,
max_workers: int | None = None,
) -> tuple[DataFrame, ...]
Load a number of data files
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
files_to_load
|
Iterable[Path]
|
Files to load |
required |
backend_data
|
OpenSCMDBDataBackend
|
Data backend to use to load the files |
required |
parallel_op_config
|
ParallelOpConfig | None
|
Configuration for executing the operation in parallel with progress bars If not supplied, we use the values of |
None
|
progress
|
bool
|
Should progress bar(s) be used to display the progress of the deletion? Only used if |
False
|
max_workers
|
int | None
|
Maximum number of workers to use for parallel processing. If supplied, we create an instance of
concurrent.futures.ProcessPoolExecutor
with the provided number of workers.
A process pool seems to be the sensible default from our experimentation,
but it is not a universally better choice.
If you need something else because of how your database is set up,
simply pass If not supplied, the loading is executed serially. Only used if |
None
|
Returns:
| Type | Description |
|---|---|
tuple[DataFrame, ...]
|
Loaded data from each file |
See Also
load_data, which loads data while applying selectors (in contrast to this function which just loads all data).
Source code in src/pandas_openscm/db/loading.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
load_db_file_map #
load_db_file_map(
*,
backend_index: OpenSCMDBIndexBackend,
file_map_file: Path,
) -> Series[Path]
Load database file map from file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend_index
|
OpenSCMDBIndexBackend
|
Backend to use to load the index |
required |
file_map_file
|
Path
|
File from which to load the file map |
required |
Returns:
| Type | Description |
|---|---|
Series[Path]
|
Loaded file map |
Source code in src/pandas_openscm/db/loading.py
load_db_index #
load_db_index(
*,
backend_index: OpenSCMDBIndexBackend,
index_file: Path,
) -> DataFrame
Load database index from file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend_index
|
OpenSCMDBIndexBackend
|
Backend to use to load the index |
required |
index_file
|
Path
|
File from which to load the index |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Loaded index |
Source code in src/pandas_openscm/db/loading.py
load_db_metadata #
load_db_metadata(
*,
backend_index: OpenSCMDBIndexBackend,
index_file: Path,
) -> MultiIndex
Load database metadata from file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend_index
|
OpenSCMDBIndexBackend
|
Backend to use to load the index |
required |
index_file
|
Path
|
File from which to load the index (from which the metadata is inferred) |
required |
Returns:
| Type | Description |
|---|---|
MultiIndex
|
Loaded metadata |