aggdisagg 1.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,42 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.10", "3.11", "3.12"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Install uv
20
+ uses: astral-sh/setup-uv@v3
21
+ with:
22
+ version: "latest"
23
+
24
+ - name: Set up Python ${{ matrix.python-version }}
25
+ run: uv python install ${{ matrix.python-version }}
26
+
27
+ - name: Install dependencies
28
+ run: |
29
+ uv sync --all-extras
30
+
31
+ - name: Lint with ruff
32
+ run: uv run ruff check .
33
+
34
+ - name: Type check with pyright
35
+ run: uv run pyright src
36
+
37
+ - name: Test with pytest
38
+ run: uv run pytest --cov=aggdisagg --cov-report=xml
39
+
40
+ - name: Upload coverage
41
+ uses: codecov/codecov-action@v3
42
+ if: matrix.python-version == '3.12'
@@ -0,0 +1,38 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+ - name: Install uv
13
+ uses: astral-sh/setup-uv@v3
14
+ - name: Build
15
+ run: uv build
16
+ - name: Upload artifact
17
+ uses: actions/upload-artifact@v4
18
+ with:
19
+ name: dist
20
+ path: dist/
21
+
22
+ publish:
23
+ needs: build
24
+ runs-on: ubuntu-latest
25
+ environment:
26
+ name: release
27
+ url: https://pypi.org/p/aggdisagg
28
+ permissions:
29
+ id-token: write
30
+ steps:
31
+ - uses: actions/download-artifact@v4
32
+ with:
33
+ name: dist
34
+ path: dist/
35
+ - name: Publish to PyPI
36
+ uses: pypa/gh-action-pypi-publish@release/v1
37
+ # For TestPyPI first (optional): use a separate job or environment "testpypi" + --repository testpypi
38
+
@@ -0,0 +1,163 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ *.manifest
31
+ *.spec
32
+
33
+ # Installer logs
34
+ pip-log.txt
35
+ pip-delete-this-directory.txt
36
+
37
+ # Unit test / coverage reports
38
+ htmlcov/
39
+ .tox/
40
+ .nox/
41
+ .coverage
42
+ .coverage.*
43
+ .cache
44
+ nosetests.xml
45
+ coverage.xml
46
+ *.cover
47
+ *.py,cover
48
+ .hypothesis/
49
+ .pytest_cache/
50
+ cover/
51
+
52
+ # Translations
53
+ *.mo
54
+ *.pot
55
+
56
+ # Django stuff
57
+ *.log
58
+ local_settings.py
59
+ db.sqlite3
60
+ db.sqlite3-journal
61
+
62
+ # Flask stuff
63
+ instance/
64
+ .webassets-cache
65
+
66
+ # Scrapy stuff
67
+ .scrapy
68
+
69
+ # Sphinx documentation
70
+ docs/_build/
71
+
72
+ # PyBuilder
73
+ .pybuilder/
74
+ target/
75
+
76
+ # Jupyter Notebook
77
+ .ipynb_checkpoints
78
+
79
+ # IPython
80
+ profile_default/
81
+ ipython_config.py
82
+
83
+ # pyenv
84
+ .python-version
85
+
86
+ # pipenv
87
+ Pipfile.lock
88
+
89
+ # poetry
90
+ poetry.lock
91
+
92
+ # pdm
93
+ .pdm.toml
94
+ .pdm-python
95
+ .pdm-build/
96
+
97
+ # pyflow
98
+ __pypackages__/
99
+
100
+ # Celery stuff
101
+ celerybeat-schedule
102
+ celerybeat.pid
103
+
104
+ # SageMath parsed files
105
+ *.sage.py
106
+
107
+ # Environments
108
+ .env
109
+ .venv
110
+ env/
111
+ venv/
112
+ ENV/
113
+ env.bak/
114
+ venv.bak/
115
+
116
+ # Spyder project settings
117
+ .spyderproject
118
+ .spyproject
119
+
120
+ # Rope project settings
121
+ .ropeproject
122
+
123
+ # mkdocs documentation
124
+ /site
125
+
126
+ # mypy
127
+ .mypy_cache/
128
+ .dmypy.json
129
+ dmypy.json
130
+
131
+ # Pyre type checker
132
+ .pyre/
133
+
134
+ # pytype static type analyzer
135
+ .pytype/
136
+
137
+ # Cython debug symbols
138
+ cython_debug/
139
+
140
+ # Ruff
141
+ .ruff_cache/
142
+
143
+ # Pyright
144
+ pyrightconfig.json
145
+
146
+ # OS generated files
147
+ .DS_Store
148
+ .DS_Store?
149
+ ._*
150
+ .Spotlight-V100
151
+ .Trashes
152
+ ehthumbs.db
153
+ Thumbs.db
154
+
155
+ # IDE
156
+ .idea/
157
+ .vscode/
158
+ *.swp
159
+ *.swo
160
+ *~
161
+
162
+ # uv
163
+ uv.lock
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ conduct@aggdisagg.dev.
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 aggdisagg contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,183 @@
1
+ Metadata-Version: 2.4
2
+ Name: aggdisagg
3
+ Version: 1.0.3
4
+ Summary: Temporal Aggregation & Disaggregation for Modern Python (Polars-first)
5
+ Project-URL: Homepage, https://github.com/aggdisagg/aggdisagg
6
+ Project-URL: Repository, https://github.com/aggdisagg/aggdisagg
7
+ Project-URL: Issues, https://github.com/aggdisagg/aggdisagg/issues
8
+ Project-URL: Documentation, https://aggdisagg.readthedocs.io
9
+ Author: aggdisagg Contributors
10
+ License: MIT
11
+ License-File: LICENSE
12
+ Keywords: econometrics,frequency-conversion,pandas,polars,temporal-aggregation,temporal-disaggregation,time-series
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
23
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
24
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
+ Requires-Python: >=3.10
26
+ Requires-Dist: numpy>=1.24.0
27
+ Requires-Dist: polars>=1.0.0
28
+ Requires-Dist: scipy>=1.10.0
29
+ Provides-Extra: all
30
+ Requires-Dist: pandas>=2.0.0; extra == 'all'
31
+ Requires-Dist: plotly>=5.0.0; extra == 'all'
32
+ Requires-Dist: scikit-learn>=1.3.0; extra == 'all'
33
+ Requires-Dist: sktime>=0.25.0; extra == 'all'
34
+ Requires-Dist: statsforecast>=1.5.0; extra == 'all'
35
+ Requires-Dist: xarray>=2023.0.0; extra == 'all'
36
+ Provides-Extra: pandas
37
+ Requires-Dist: pandas>=2.0.0; extra == 'pandas'
38
+ Provides-Extra: plot
39
+ Requires-Dist: plotly>=5.0.0; extra == 'plot'
40
+ Provides-Extra: sklearn
41
+ Requires-Dist: scikit-learn>=1.3.0; extra == 'sklearn'
42
+ Provides-Extra: sktime
43
+ Requires-Dist: sktime>=0.25.0; extra == 'sktime'
44
+ Provides-Extra: statsforecast
45
+ Requires-Dist: statsforecast>=1.5.0; extra == 'statsforecast'
46
+ Provides-Extra: xarray
47
+ Requires-Dist: xarray>=2023.0.0; extra == 'xarray'
48
+ Description-Content-Type: text/markdown
49
+
50
+ # aggdisagg
51
+
52
+ > **Temporal Aggregation & Disaggregation for Modern Python**
53
+
54
+ [![Python](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org)
55
+ [![Polars](https://img.shields.io/badge/Polars-first-orange)](https://pola.rs)
56
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
57
+ [![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)
58
+ [![PyPI](https://img.shields.io/pypi/v/aggdisagg)](https://pypi.org/project/aggdisagg/)
59
+ [![GitHub](https://img.shields.io/badge/GitHub-aggdisagg-black?logo=github)](https://github.com/aggdisagg/aggdisagg)
60
+
61
+ <!-- GitHub social preview: the image below is auto-generated for social sharing -->
62
+ ![aggdisagg social preview](https://opengraph.githubassets.com/1/aggdisagg/aggdisagg)
63
+
64
+ **Install & try in 10 seconds:**
65
+
66
+ ```bash
67
+ pip install aggdisagg
68
+ ```
69
+
70
+ ```python
71
+ import polars as pl
72
+ from aggdisagg import TemporalAligner
73
+ df = pl.DataFrame({"date": ["2020", "2021"], "y": [100.0, 120.0]})
74
+ print(TemporalAligner().fit_transform(df, datetime_col="date", target_col="y"))
75
+ ```
76
+
77
+ **aggdisagg** is a clean, **Polars-first** Python library for converting time series between frequencies with **perfect aggregation consistency**.
78
+
79
+ - Disaggregate low → high frequency (with indicators)
80
+ - Aggregate high → low frequency (symmetric)
81
+ - Works with **Polars** (primary), **pandas**, and **xarray**
82
+
83
+ ## Installation + Try in 10 Seconds
84
+
85
+ ```bash
86
+ pip install "aggdisagg[all]" && python -c "
87
+ import polars as pl
88
+ from datetime import date
89
+ from aggdisagg import TemporalAligner
90
+ df = pl.DataFrame({'date':[date(2020,1,1),date(2021,1,1)], 'y':[1000.,1200.]})
91
+ print(TemporalAligner(method='uniform').fit_transform(df, datetime_col='date', target_col='y'))
92
+ "
93
+ ```
94
+
95
+ ## Quickstart with `TemporalAligner`
96
+
97
+ ```python
98
+ import polars as pl
99
+ from datetime import date
100
+ from aggdisagg import TemporalAligner
101
+
102
+ df = pl.DataFrame({
103
+ "date": [date(2020, 1, 1), date(2021, 1, 1), date(2022, 1, 1)],
104
+ "y": [1200.0, 1500.0, 1350.0], # low-frequency target
105
+ "indicator": [100.0, 125.0, 110.0], # high-frequency indicator
106
+ })
107
+
108
+ aligner = TemporalAligner(
109
+ method="chow-lin-opt",
110
+ target_freq="1mo",
111
+ agg="sum",
112
+ indicator_cols=["indicator"],
113
+ )
114
+
115
+ monthly = aligner.fit_transform(df, datetime_col="date", target_col="y")
116
+ print(monthly.head())
117
+
118
+ # Perfect symmetric aggregation
119
+ yearly_back = aligner.aggregate(monthly, freq="1y")
120
+ print("Roundtrip OK:", (yearly_back["y_1y"] - df["y"]).abs().sum() < 1e-8)
121
+
122
+ # Plot (requires plotly)
123
+ monthly.plot() # or use .plot() on the result if extended
124
+ ```
125
+
126
+ ## Supported Methods
127
+
128
+ - `uniform`
129
+ - `linear`
130
+ - `denton` / `denton-cholette`
131
+ - `chow-lin`, `chow-lin-opt` (auto ρ via maxlog/minrss)
132
+ - `litterman`, `fernandez`
133
+
134
+ All methods guarantee `C @ y_high ≈ y_low` exactly.
135
+
136
+ ## Why aggdisagg?
137
+
138
+ - **Polars-native** core (lazy-friendly)
139
+ - **Perfect consistency** by construction (C/D matrices)
140
+ - **Sklearn-style** + fluent API
141
+ - Real econometric methods (Denton quadratic, Chow-Lin GLS)
142
+ - Excellent pandas / xarray interop
143
+ - Production quality (typed, tested, documented)
144
+
145
+ ## v0.2 Highlights
146
+
147
+ - Hierarchical reconciliation (national → regional)
148
+ - Uncertainty (bootstrap + analytic std errors)
149
+ - Full Polars lazy + xarray DataArray I/O
150
+ - Negative post-correction + NNLS ensemble
151
+ - sktime / statsforecast compatible wrapper
152
+
153
+ ```python
154
+ # Hierarchical
155
+ rec = aligner.reconcile_hierarchical([nat_df, reg_df])
156
+
157
+ # Uncertainty
158
+ mean, std = aligner.predict_with_uncertainty()
159
+
160
+ # Lazy + xarray
161
+ lazy_high = aligner.fit_transform(lazy_df)
162
+ xa = aligner.to_xarray(high_df)
163
+ ```
164
+
165
+ See `examples/quickstart.py` for complete gallery.
166
+
167
+ ## Development & Publishing
168
+
169
+ ```bash
170
+ uv sync --all-extras
171
+ uv run pytest
172
+ uv run python examples/quickstart.py
173
+ uv build
174
+ # twine or uv publish
175
+ ```
176
+
177
+ ## License
178
+
179
+ MIT
180
+
181
+ ---
182
+
183
+ **Built for data scientists who want temporal frequency conversion that just works.**