Metadata-Version: 2.4
Name: frequenz-resampling
Version: 0.1.0
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Software Development :: Libraries
Classifier: Typing :: Typed
Requires-Dist: typing-extensions>=4.14.1,<5
Requires-Dist: frequenz-resampling[dev-mkdocs,dev-flake8,dev-formatting,dev-mkdocs,dev-mypy,dev-noxfile,dev-pylint,dev-pytest] ; extra == 'dev'
Requires-Dist: flake8==7.3.0 ; extra == 'dev-flake8'
Requires-Dist: flake8-datetimez==20.10.0 ; extra == 'dev-flake8'
Requires-Dist: flake8-docstrings==1.7.0 ; extra == 'dev-flake8'
Requires-Dist: flake8-pyproject==1.2.4 ; extra == 'dev-flake8'
Requires-Dist: pydoclint==0.8.3 ; extra == 'dev-flake8'
Requires-Dist: pydocstyle==6.3.0 ; extra == 'dev-flake8'
Requires-Dist: black==26.3.1 ; extra == 'dev-formatting'
Requires-Dist: isort==6.0.0 ; extra == 'dev-formatting'
Requires-Dist: markdown==3.10.2 ; extra == 'dev-mkdocs'
Requires-Dist: black==26.3.1 ; extra == 'dev-mkdocs'
Requires-Dist: mike==2.2.0 ; extra == 'dev-mkdocs'
Requires-Dist: mkdocs-gen-files==0.6.1 ; extra == 'dev-mkdocs'
Requires-Dist: mkdocs-literate-nav==0.6.3 ; extra == 'dev-mkdocs'
Requires-Dist: mkdocs-macros-plugin==1.5.0 ; extra == 'dev-mkdocs'
Requires-Dist: mkdocs-material==9.7.6 ; extra == 'dev-mkdocs'
Requires-Dist: mkdocstrings[python]==1.0.4 ; extra == 'dev-mkdocs'
Requires-Dist: mkdocstrings-python==2.0.3 ; extra == 'dev-mkdocs'
Requires-Dist: frequenz-repo-config[lib]==0.17.0 ; extra == 'dev-mkdocs'
Requires-Dist: mypy==1.20.2 ; extra == 'dev-mypy'
Requires-Dist: types-markdown==3.10.2.20260408 ; extra == 'dev-mypy'
Requires-Dist: frequenz-resampling[dev-mkdocs,dev-noxfile,dev-pytest] ; extra == 'dev-mypy'
Requires-Dist: nox==2026.4.10 ; extra == 'dev-noxfile'
Requires-Dist: frequenz-repo-config[lib]==0.17.0 ; extra == 'dev-noxfile'
Requires-Dist: frequenz-resampling[dev-mkdocs,dev-noxfile,dev-pytest] ; extra == 'dev-pylint'
Requires-Dist: pytest==9.0.3 ; extra == 'dev-pytest'
Requires-Dist: pylint==4.0.5 ; extra == 'dev-pytest'
Requires-Dist: pandas==2.3.3 ; extra == 'dev-pytest'
Requires-Dist: pandas-stubs==2.3.2.250926 ; extra == 'dev-pytest'
Requires-Dist: frequenz-repo-config[extra-lint-examples]==0.17.0 ; extra == 'dev-pytest'
Requires-Dist: pytest-mock==3.15.1 ; extra == 'dev-pytest'
Requires-Dist: pytest-asyncio==1.3.0 ; extra == 'dev-pytest'
Requires-Dist: async-solipsism==0.9 ; extra == 'dev-pytest'
Provides-Extra: dev
Provides-Extra: dev-flake8
Provides-Extra: dev-formatting
Provides-Extra: dev-mkdocs
Provides-Extra: dev-mypy
Provides-Extra: dev-noxfile
Provides-Extra: dev-pylint
Provides-Extra: dev-pytest
License-File: LICENSE
Summary: A library for resampling a stream of samples to a given interval.
Keywords: frequenz,python,lib,library,frequenz-resampling,rust,python
Author-email: Frequenz Energy-as-a-Service GmbH <floss@frequenz.com>
License-Expression: MIT
Requires-Python: >=3.11, <4
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Changelog, https://github.com/frequenz-floss/frequenz-resampling-python/releases
Project-URL: Documentation, https://frequenz-floss.github.io/frequenz-resampling-python/
Project-URL: Issues, https://github.com/frequenz-floss/frequenz-resampling-python/issues
Project-URL: Repository, https://github.com/frequenz-floss/frequenz-resampling-python
Project-URL: Support, https://github.com/frequenz-floss/frequenz-resampling-python/discussions/categories/support

# Frequenz Resampling

[![Build Status](https://github.com/frequenz-floss/frequenz-resampling-python/actions/workflows/ci.yaml/badge.svg)](https://github.com/frequenz-floss/frequenz-resampling-python/actions/workflows/ci.yaml)
[![PyPI Package](https://img.shields.io/pypi/v/frequenz-resampling)](https://pypi.org/project/frequenz-resampling/)
[![Docs](https://img.shields.io/badge/docs-latest-informational)](https://frequenz-floss.github.io/frequenz-resampling-python/)

## Introduction

`frequenz-resampling` provides fast, typed resampling for timestamped numeric
data in Python.

The library is backed by the Rust resampler
[`frequenz-floss/frequenz-resampling-rs`](https://github.com/frequenz-floss/frequenz-resampling-rs)
and exposed through a small Python API. It supports incremental stream
resampling through a `Resampler` object as well as one-shot resampling with the
`resample()` convenience function.

Main capabilities:

- fixed-interval resampling with timezone-aware `datetime` timestamps
- configurable interval semantics via `Closed` and `Label`
- multiple aggregation functions via `ResamplingFunction`:
  `AVERAGE`, `SUM`, `MAX`, `MIN`, `FIRST`, `LAST`, `COUNT`, `COALESCE`
- typed Python API (`py.typed`) and generated API docs

## Supported Platforms

The following platforms are officially supported (tested):

- **Python:** 3.11, 3.12, 3.13, 3.14
- **Operating System:** Ubuntu Linux 24.04, Windows, macOS
- **Architectures:** amd64, arm64

## Quick Start

### Install

```sh
python -m pip install frequenz-resampling
```

### Stream resampling with `Resampler`

```python
import datetime as dt

from frequenz.resampling import Closed, Label, Resampler, ResamplingFunction

start = dt.datetime(1970, 1, 1, tzinfo=dt.timezone.utc)
step = dt.timedelta(seconds=1)

resampler = Resampler(
    dt.timedelta(seconds=5),
    ResamplingFunction.AVERAGE,
    max_age_in_intervals=1,
    start=start,
    closed=Closed.LEFT,
    label=Label.RIGHT,
)

for i in range(10):
    resampler.push_sample(timestamp=start + i * step, value=float(i + 1))

result = resampler.resample(start + 10 * step)
print(result)
# [(1970-01-01 00:00:05+00:00, 3.0), (1970-01-01 00:00:10+00:00, 8.0)]
```

### One-shot resampling with `resample()`

```python
import datetime as dt

from frequenz.resampling import Closed, Label, ResamplingFunction, resample

start = dt.datetime(1970, 1, 1, tzinfo=dt.timezone.utc)
step = dt.timedelta(seconds=1)
data = [(start + i * step, float(i + 1)) for i in range(10)]

result = resample(
    data,
    dt.timedelta(seconds=5),
    ResamplingFunction.SUM,
    closed=Closed.LEFT,
    label=Label.RIGHT,
)
print(result)
```

## Documentation

- User and API documentation:
  <https://frequenz-floss.github.io/frequenz-resampling-python/>
- Changelog / releases:
  <https://github.com/frequenz-floss/frequenz-resampling-python/releases>

## Contributing

Contributions are welcome. For development setup, testing, docs, and release
workflow, see the [Contributing Guide](CONTRIBUTING.md).

## License

This project is licensed under the [MIT License](LICENSE).

