demetrapy
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
power_model = result.for_series("power").arima_model
print(adjusted.tail())
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_forecast_frame() for future values, to_combined_frame() for one
history-plus-forecast table, 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
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
- Read the documentation
- Quickstart
- Usage
- Configuration reference
- Examples
- Copy, run, inspect notebook
- Windows and offline setup
- Compatibility
demetrapy is an independent interface to JDemetra+ and is not an official
publication of the JDemetra+ project.
Release files for demetrapy 0.3.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| demetrapy-0.3.4.tar.gz | 64.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| demetrapy-0.3.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 117.7 kB
Release files / demetrapy-0.3.4.tar.gz
| Download URL | demetrapy-0.3.4.tar.gz |
|---|---|
| Size | 64.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ada58fe43165eef74b542d801f48dfe5c6f5e91eb6561c3b2406e65a1d8a3d4e
|
|
BLAKE2b-256 checksum How to use checksums |
621c2e78dd01aba921496ecb45a08a9281ca508926abd074f693046aedb7b08f
|
| 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.4-py3-none-any.whl
| Download URL | demetrapy-0.3.4-py3-none-any.whl |
|---|---|
| Size | 53.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
828547998e0ae062303adac7f6e5e4e09aeb13a768c44da45239bc27b0453376
|
|
BLAKE2b-256 checksum How to use checksums |
aa0f3c051b77f437b6e4a6ed541918a50e3f9c4c99b75691ce951254325ba44d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|