Evenly distribute items into batches
Project description
batch-evenly
Distribute items into evenly-sized batches.
Installation
pip install batch-evenly
Usage
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
batch_evenly-0.1.0.tar.gz
(52.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file batch_evenly-0.1.0.tar.gz.
File metadata
- Download URL: batch_evenly-0.1.0.tar.gz
- Upload date:
- Size: 52.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b3dcaf3112a01fad8a36912b2ceab312d0af37fd0ef1c636e293ea6f9b6bc87
|
|
| MD5 |
a27a66b52565fa6cf62ac4630c11dae8
|
|
| BLAKE2b-256 |
1f5673cff4fb434b1db85f5c56607eebeddccbdecc1d9614efbe4b07aa03479d
|
File details
Details for the file batch_evenly-0.1.0-py3-none-any.whl.
File metadata
- Download URL: batch_evenly-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f157463ee9e19afdb65bf4019bda122d3ba312c6a5f3e2aa1f1faf043e44229a
|
|
| MD5 |
9db8fae1abfe77f2fabfacc47cbdb496
|
|
| BLAKE2b-256 |
8096c22bda9bdb07e486cdcf25eb816909c47f91b573c0568852a423420f964a
|