Skip to main content

demetrapy

PyPI Python CI Documentation Status

Run JDemetra+ TRAMO/SEATS directly from Python. demetrapy turns pandas data into seasonally adjusted series, forecasts, diagnostics, and fitted-model metadata without a desktop workspace or XML workflow.

Why demetrapy

  • Run TRAMO/SEATS across every numeric DataFrame column with one call.
  • Receive components and forecasts as date-indexed pandas DataFrames.
  • Inspect diagnostics, processing messages, and fitted ARIMA models in Python.
  • Assign different user-defined calendar variables to each target series.
  • Reproduce reviewed workflows with typed configuration or JSON.

Install

Python 3.11+ and Java 9+ are required.

python -m pip install demetrapy
demetrapy check

To run the example notebook, install the optional Jupyter dependencies:

python -m pip install "demetrapy[notebook]"

The first adjustment downloads the pinned JDemetra+ 2.2.6 core JAR to ~/.cache/demetrapy. Set DEMETRAPY_JAR to use a local copy instead.

TRAMO/SEATS in Python

This complete example adjusts ten synthetic monthly emissions series, requests a one-year forecast, and keeps detailed model results:

from demetrapy import TramoSeatsConfig, adjust_dataframe, load_monthly_emissions

data = load_monthly_emissions()
result = adjust_dataframe(
    data,
    config=TramoSeatsConfig(
        spec="RSAfull",
        preprocessing={"automodel": {"enabled": True}},
        seats={"prediction_length": 12},
    ),
    detailed=True,
)

adjusted = result.seasonally_adjusted  # date index x 10 series
forecasts = result.to_forecast_frame() # future component DataFrames
summary = result.to_summary_frame()    # one row per input series
report = result.to_html_report("tramoseats_report.html")
power_model = result.for_series("power").arima_model

print(adjusted.tail())
print(summary[["series", "arima", "diagnostic_count", "forecast_periods"]])
print(power_model.notation if power_model else "Model metadata unavailable")

adjust_dataframe() infers monthly, quarterly, half-yearly, or yearly frequency from a regular DatetimeIndex. Each column is processed independently and every result contains six components:

Component Alias Meaning
observed y input series
calendar_adjusted ycal calendar effects removed
seasonally_adjusted sa seasonal effects removed
trend t trend-cycle
seasonal s seasonal component
irregular i irregular component

Use to_summary_frame() to compare processing metadata across every target, to_forecast_frame() for future values, to_combined_frame() for one history-plus-forecast table, to_html_report() for an offline interactive review, and for_series(name) to inspect one fitted model's diagnostics and messages.

Different Calendars for Different Series

Calendar variables live in a separate DataFrame. A mapping selects which pool columns enter each target's model. Extra pool columns are allowed.

result = adjust_dataframe(
    observations,
    calendar_pool=calendar_variables,
    user_defined_calendars={
        "power": ["heating_days", "working_days"],
        "transport": ["working_days", "holiday_days", "mobility_index"],
    },
    config=config,
)

See the complete 10-series example with extended TRAMO/SEATS parameters: examples/13_full_config_calendar_pool.py.

More Workflows

TRAMO/SEATS is the primary workflow. The same API also supports single sequences, X13/X11, CSV automation, a command-line interface, and a Streamlit dashboard.

A sequence has no dates, so its frequency and start must be explicit:

from demetrapy import adjust

result = adjust(
    values,
    frequency="Quarterly",
    start_year=2010,
    start_period=1,
    method="tramoseats",
    spec="RSAfull",
)

For batch integration, CSV files use the same processing engine:

from demetrapy import adjust_csv

result = adjust_csv("input.csv", config="tramoseats.json", output="adjusted.csv")

X13/X11 remains available through X13Config or method="x13" when that is the required specification.

Command Line

demetrapy input.csv --output adjusted.csv
demetrapy init-config --method tramoseats --output config.json
demetrapy validate config.json --data input.csv
demetrapy input.csv --config config.json --output adjusted.csv --audit audit/

Dashboard

The included Streamlit dashboard runs the same X13 and TRAMO/SEATS engine as the Python API. Start with a built-in monthly, quarterly, or calendar-adjusted dataset, or upload your own files.

demetrapy-dashboard
image

From the dashboard you can:

  • adjust one or several target columns;
  • upload JSON configuration and a separate calendar-variable pool;
  • map different calendar variables to each target;
  • inspect interactive components and forecasts;
  • review diagnostics, processing messages, and fitted models;
  • download result tables.

Ready-to-upload files are available in the dashboard example directory.

Documentation

demetrapy is an independent interface to JDemetra+ and is not an official publication of the JDemetra+ project.

Release files for demetrapy 0.3.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for demetrapy 0.3.6
File Size Uploaded
demetrapy-0.3.6.tar.gz 68.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for demetrapy 0.3.6
File Interpreter ABI Platform
demetrapy-0.3.6-py3-none-any.whl Python 3 none any Details

Total release size: 124.8 kB

Release files / demetrapy-0.3.6.tar.gz

Download URL demetrapy-0.3.6.tar.gz
Size 68.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f64ba26d6386fe2a08a8dbec5036a2ef52551fa6c1c5071e8f0c61b3272d6f87
BLAKE2b-256 checksum
How to use checksums
d60a6bfae6bc4ac862ea6d38c7224d76f8a4699d3bc9ae96aac912862f7f04c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / demetrapy-0.3.6-py3-none-any.whl

Download URL demetrapy-0.3.6-py3-none-any.whl
Size 56.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c2b7bb558dd39a2baf0bbc127806179594e034030c837b342fed5798dc1781d4
BLAKE2b-256 checksum
How to use checksums
67717bcfd4e1b4c1505fb162f78fe98a11771fcc54e2c22d1bd222e403ef0b0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release history Release notifications | RSS feed

0.3.7

2 release files

This release

0.3.6 This release

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page