No project description provided
Project description
Quickstart
Step 1: Install the data package in your DISPATCHES environment using pip
conda activate dispatches-dev # or the name of your DISPATCHES dev environment
pip install git+https://github.com/gmlc-dispatches/dynamic-sweep-data
Step 2: Access the contents of the data package in your code using dispatches_data.api
Using dispatches_data.api.path()
:
from dispatches_data.api import path
# path_to_data_package is a standard pathlib.Path object
path_to_data_package = path("dynamic_sweep")
# subdirectories and files can be accessed using the pathlib.Path API
path_to_NE_results = path_to_data_package / "NE" / "sweep_parameters_results_NE_whole.h5"
assert path_to_NE_results.is_file()
# if the path must be passed to a function that only accepts `str` objects, it can be converted using `str()`
path_to_NE_results_as_str = str(path_to_NE_results)
Using dispatches_data.api.files()
:
from dispatches_data.api import files
# paths_to_all_results_files will be a list of pathlib.Path objects for each file matching the specified `pattern`
paths_to_all_results_files = files("dynamic_sweep", pattern="**/sweep_parameters_results_*_whole.h5")
# check that the list of found files is not empty
assert paths_to_all_results_files
# `dispatches_data.api.files()` always returns a list, even if only one file matches
path_to_NE_results = files("dynamic_sweep", pattern="NE/*result_*_whole.h5")[0]
Examples
Loading multiple CSV files into a pandas DataFrame
import pandas as pd
from dispatches_data.api import files
def load_data(case_study: str = "NE") -> pd.DataFrame:
results_file_pattern = f"{case_study}/results_*_sweep_*/*.csv"
csv_files_to_load = files("dynamic_sweep", pattern=results_files_pattern)
if not csv_files_to_load:
raise LookupError("No files found with pattern {results_file_pattern!r}")
df = pd.concat(
[pd.read_csv(csv_path) for csv_path in csv_files_to_load],
axis="index"
)
# process df as needed
return df
def main():
df_NE = load_data("NE")
df_RE = load_data("RE")
...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file dispatches-dynamic-sweep-data-23.7.24.tar.gz
.
File metadata
- Download URL: dispatches-dynamic-sweep-data-23.7.24.tar.gz
- Upload date:
- Size: 72.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 132376b07b8c61434c9aca60cf38f2328b3a4a9fca61dfa5dcbd1b2077a2423f |
|
MD5 | 9074da365beaffee550cd051a45c72f4 |
|
BLAKE2b-256 | 5f18fcb1edde3dbbfa4ba1ab4b1743c6ecc6b3768ad5e009003ac470d8340162 |
File details
Details for the file dispatches_dynamic_sweep_data-23.7.24-py3-none-any.whl
.
File metadata
- Download URL: dispatches_dynamic_sweep_data-23.7.24-py3-none-any.whl
- Upload date:
- Size: 76.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ac040c75a6b2f6ddf74d5d292f4e7668e86e8c8a68702b4193eaa2855c12039 |
|
MD5 | f81f618ac8ec913531d78b7cd01b90bd |
|
BLAKE2b-256 | e16a46feee15a151e5386239aab5d80764fb8b8a5c2861fecabba63b10dcd7d2 |