Gives functions to help build a mater providing data script.
Project description
MATER data providing
Metabolic Analysis for Transdisciplinary Ecological Research
[TOC]
📋 Requirements
- Python 3.12 or higher
We recommend using one virtual environment per Python project to manage dependencies and maintain isolation. You can use a package manager like uv to help you with library dependencies and virtual environments.
📦 Install the mater-data-providing Package
Install the mater package via uv:
uv add mater-data-providing
Install the mater package via pip:
pip install mater-data-providing
⚙️ API
metadata_definition
import mater-data-providing as mdp
mdp.metadata_definition("source_link", "my_source", "my_project")
Returns
{"link": "source_link", "source": "my_source", "project": "my_project"}
provider_definition
import mater-data-providing as mdp
mdp.provider_definition("Jon", "Do", "jon.do@mail.com")
Returns
{"first_name": "Jon", "last_name": "Do", "email_address": "jon.do@mail.com"}
to_json
import mater_data_providing as mdp
import pandas as pd
# 1. Build a DataFrame
df = pd.DataFrame([
{"location": "france", "object": "car", "value": 15, "unit": "year", "time": 2015, "scenario": "historical", "variable": "lifetime_mean_value"},
{"location": "france", "object": "car", "value": 17, "unit": "year", "time": 2020, "scenario": "historical", "variable": "lifetime_mean_value"},
])
# 2. Write out as "input_data/sample.json"
# (creates data/input_data/sample.json)
mdp.to_json(
df,
folder="input_data",
name="sample", # filename will be sample.json
mode="w" # write (overwrite) – this is the default
)
Creates data/input_data/sample.json:
[
{
"location": "france",
"object": "car",
"value": 15,
"unit": "year",
"time": 2015,
"scenario": "historical",
"variable": "lifetime_mean_value"
},
{
"location": "france",
"object": "car",
"value": 17,
"unit": "year",
"time": 2020,
"scenario": "historical",
"variable": "lifetime_mean_value"
}
]
replace_equivalence
data\dimension\dimension.json:
[
{
"value": "car",
"equivalence": {
"short": "PLDV",
"long": "personal_vehicle"
}
},
{
"value": "france",
"equivalence": {
"ISO3": "FRA"
}
}
]
Python scrip at the root of the project:
import mater_data_providing as mdp
import pandas as pd
# 1. Build a DataFrame
df = pd.DataFrame([
{"location": "FRA", "object": "personal_vehicle", "value": 15, "unit": "year", "time": 2015, "scenario": "historical", "variable": "lifetime_mean_value"},
{"location": "france", "object": "PLDV", "value": 17, "unit": "year", "time": 2020, "scenario": "historical", "variable": "lifetime_mean_value"},
])
df_uniform = mdp.replace_equivalence(df)
print(df_uniform)
location object value unit time scenario variable
0 france car 15 year 2015 historical lifetime_mean_value
1 france car 17 year 2020 historical lifetime_mean_value
Project details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mater_data_providing-0.1.0.tar.gz.
File metadata
- Download URL: mater_data_providing-0.1.0.tar.gz
- Upload date:
- Size: 43.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b430d47bcdd6b4d44440ca1029a511f00bf90093cc375a6f14dbaf1de71aa25e
|
|
| MD5 |
30cb6ff7d05d534fe3b7b8a125024ebf
|
|
| BLAKE2b-256 |
742325b40ee3c07b73cdb31043853a8b9f0a508156bfbe62503d62844dde4a1a
|
File details
Details for the file mater_data_providing-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mater_data_providing-0.1.0-py3-none-any.whl
- Upload date:
- Size: 29.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89de4c543a15c2ffb8243d67ae0eded1d9f0a0aed4f14d57cccd4ad135f5ca40
|
|
| MD5 |
ba69c3daba41c18dd0514d6cd416ffe8
|
|
| BLAKE2b-256 |
a5623884e6f9b51757039f9398c1202fafaa8befc24371686139e7e06d45c952
|