No project description provided
Project description
Dollop
A python package for splitting up iterables into smaller portions 🥣.
Usage
Supports:
- Sequences:
list,tuple,str,range,bytes,bytearrayor any other sequence-like object. - Pandas objects:
DataFrame,Series. - Files: either as a file path or handle.
Example usage (automatically checks object type):
from dollop import serve
dollops = serve(items, serving_size=10)
for dollop in dollops:
do_something(dollop)
The serving_size parameter defines how many items/lines/characters/etc. you want in each dollop!
To use type-specific dollop:
- Sequences:
from dollop.sequence import serve. - Pandas:
from dollop.pandas import serve - Files:
from dollop.file import serve.
For dollop.file you can specify mode=lines or mode=chars to read the file line-by-line or character-by-character.
See also
The more_itertools and later (Python 3.12+) itertools packages have something similar:
from more_itertools import chunked
chunks = chunked(iterable, n))
and
from itertools import batched
batches = batched(iterable, n))
These both have the disadvantage that typing is not preserved.
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
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 dollop-1.0.0.tar.gz.
File metadata
- Download URL: dollop-1.0.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15658543bb8b60430b17640097affceadcd4b81f43e18bb1c023072700a47ced
|
|
| MD5 |
1554bdc3494221c156b0669dfacd435d
|
|
| BLAKE2b-256 |
9af4ad5d31afeb26c2e2b1254a85a4e0327461a860a8c49083953ecabe4074bf
|
File details
Details for the file dollop-1.0.0-py3-none-any.whl.
File metadata
- Download URL: dollop-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27b2a4b15955f1a7dc4aea473e00ae66072939d65cb80651c612e465145798c3
|
|
| MD5 |
d648aa58179e82bbe9b99591a85d8964
|
|
| BLAKE2b-256 |
92bf959c43849fb86d445aacb7674fd19323a9351e437ef47413616ec50446aa
|