Skip to main content

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.

Python 3.7+ License: MIT

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 date
  • from_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

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

petrinex-0.3.0.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

petrinex-0.3.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file petrinex-0.3.0.tar.gz.

File metadata

  • Download URL: petrinex-0.3.0.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for petrinex-0.3.0.tar.gz
Algorithm Hash digest
SHA256 962c80409e260be1cb9403921dda014bbdfa6b33f4f5d1cc2eca4571cdf98f8e
MD5 ac80b4c8cc8c1e67d6bf1771d98b092d
BLAKE2b-256 b3bef5be1b3983667283e828ca22dc36c5873937a2c5804d1f43011fbc201bdf

See more details on using hashes here.

File details

Details for the file petrinex-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: petrinex-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for petrinex-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ea98981da69eed0265b9f70e1567224c47095db9e340e243d62ffee7455d8a29
MD5 cbb309c6f808e4045cba1423c81963b2
BLAKE2b-256 ead92e25bee0737f8ff5f057e16ff8d1baf705788fb46d9e748e1d607535213d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page