Metadata-Version: 2.4
Name: batch-evenly
Version: 0.1.0
Summary: Evenly distribute items into batches
Project-URL: Homepage, https://github.com/broadinstitute/batch-evenly
Project-URL: Repository, https://github.com/broadinstitute/batch-evenly
Project-URL: Issues, https://github.com/broadinstitute/batch-evenly/issues
Author-email: Devin McCabe <dmccabe@broadinstitute.org>
License: MIT
License-File: LICENSE
Keywords: batch,distribute,partition,split
Requires-Python: >=3.8
Provides-Extra: dev
Requires-Dist: build>=1.0.0; extra == 'dev'
Requires-Dist: pandas>=1.0.0; extra == 'dev'
Requires-Dist: pyright>=1.1.0; extra == 'dev'
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Provides-Extra: pandas
Requires-Dist: pandas>=1.0.0; extra == 'pandas'
Description-Content-Type: text/markdown

# batch-evenly

Distribute items into evenly-sized batches.

## Installation

```shell
pip install batch-evenly
```

## Usage

```python
from batch_evenly import batch_evenly

# Distribute 10 items into 3 batches of at most 4 items each
for i, batch in batch_evenly(range(10), max_batch_size=4):
	print(f"Batch {i+1} ({len(batch)} items): {batch}")

# Output:
# Batch 1 (4 items): [0, 1, 2, 3]
# Batch 2 (3 items): [4, 5, 6]
# Batch 3 (3 items): [7, 8, 9]
```

## Features

- Yields evenly sized batches (e.g. in the example, `[4, 3, 3]` instead of `[4, 4, 2]`)
- Works with any iterable
- Optional support for batching Pandas DataFrames by row iteration
- Zero required dependencies

## License

MIT
