capturegraph.data.containers.utilities.zip
#
zip - Broadcasting Zip for Lists#
Combine multiple Lists (or scalars) into a single List of Dicts
for row-wise processing. Similar to zip(), but with NumPy-style broadcasting.
Example
from pathlib import Path
from capturegraph.data import zip
# Build output paths from components
base = Path("./output")
names = sessions.date.map(lambda d: f"{d:%Y%m%d}.heic")
paths = zip(dir=base, name=names).map(lambda r: r.dir / r.name)
# → List([Path("./output/20260104.heic"), ...])
# Copy files using zip
import shutil
zip(src=sessions.photo, dst=paths).map(
lambda r: shutil.copy2(r.src, r.dst)
)
Broadcasting Rules
- Same length: All Lists must have the same length
- Single-element: Lists with one element are repeated to match
- Scalars: Non-list values are repeated for every row
zip(*args, **kwargs)
#
Combine multiple Lists with NumPy-style broadcasting.
Creates a List of Dicts, where each Dict represents one row with named fields from the keyword arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
T | List[T]
|
Named Lists or scalars. - Lists are zipped element-wise. - Scalars are repeated for every row. - Single-element lists are broadcast to match the longest. |
{}
|
Returns:
| Type | Description |
|---|---|
List[Dict[Any]]
|
List of Dicts with attribute access to each field. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If List lengths are incompatible (different and not 1). |