Load Alberta Petrinex data (Volumetrics, NGL) into Spark/pandas DataFrames
Project description
Petrinex Python API
Load Alberta Petrinex data (Volumetrics, NGL) into Spark/pandas DataFrames.
Note: Currently supports Alberta (AB) jurisdiction only.
Features
- ✅ Unity Catalog & Databricks Serverless compatible
- ✅ Memory efficient - handles 60+ files without OOM
- ✅ Zero config - automatic ZIP extraction, encoding, error handling
- ✅ Multiple data types - Volumetrics and NGL support
Quick Start
pip install petrinex
from petrinex import PetrinexClient
# Volumetrics (Alberta only)
client = PetrinexClient(spark=spark, jurisdiction="AB", data_type="Vol")
df = client.read_spark_df(updated_after="2025-12-01")
# NGL and Marketable Gas
ngl_client = PetrinexClient(spark=spark, jurisdiction="AB", data_type="NGL")
ngl_df = ngl_client.read_spark_df(updated_after="2025-12-01")
API
Load Data
# Spark DataFrame (recommended)
df = client.read_spark_df(updated_after="2025-12-01")
# pandas DataFrame
pdf = client.read_pandas_df(updated_after="2025-12-01")
Date Options:
updated_after="2025-12-01"- Files modified after this datefrom_date="2021-01-01"- All data from production month onwards
Supported Data Types
| Type | Description |
|---|---|
Vol |
Conventional Volumetrics |
NGL |
NGL and Marketable Gas Volumes |
Databricks
# Install from GitHub
%pip install git+https://github.com/guanjieshen/petrinex-python-api.git
from petrinex import PetrinexClient
client = PetrinexClient(spark=spark, data_type="Vol")
df = client.read_spark_df(updated_after="2025-12-01")
display(df)
See databricks_example.ipynb for complete example.
Examples
Incremental Updates
last_update = spark.sql(
"SELECT MAX(file_updated_ts) FROM main.petrinex.volumetrics"
).first()[0]
df = client.read_spark_df(updated_after=last_update.split()[0])
Historical Backfill
df = client.read_spark_df(from_date="2020-01-01")
df.write.format("delta").mode("overwrite").saveAsTable("main.petrinex.volumetrics")
Installation
# From PyPI
pip install petrinex
# From GitHub
pip install git+https://github.com/guanjieshen/petrinex-python-api.git
# Development
git clone https://github.com/guanjieshen/petrinex-python-api.git
cd petrinex-python-api
pip install -e ".[dev]"
Testing
pytest tests/ -v # Unit tests
pytest tests/ -v -m integration # Include integration tests
pytest tests/ --cov=petrinex # With coverage
Links
- 📦 PyPI
- 📓 Databricks Example
- 🧪 Tests
- 📋 Changelog
- 🤝 Contributing
License
MIT License - Copyright (c) 2026 Guanjie Shen
See LICENSE for full details.
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 petrinex-1.0.1.tar.gz.
File metadata
- Download URL: petrinex-1.0.1.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8156ba424f1a85ed143b8b55a40846b93f123deac40a2a440ac0ad52d41b647b
|
|
| MD5 |
08394fb767be92f0f49da37e6ccfb0b5
|
|
| BLAKE2b-256 |
aecefbd87cede8044f75606d722e994d3bab13c7adf9c4da1a2f2ba2c1b8d64f
|
File details
Details for the file petrinex-1.0.1-py3-none-any.whl.
File metadata
- Download URL: petrinex-1.0.1-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05a88c660483a4b3c6d88b2f610569533481a270e261d6065c4e883ae62f264d
|
|
| MD5 |
dd77b67775690a6b28a5aaf51b30f85c
|
|
| BLAKE2b-256 |
ea5880db80c1e730bf6c055c058585b00e7e0540143948369fd72a64d5a7c464
|