zcollection.collection.Collection.map#
- Collection.map(func, /, *args, delayed=True, filters=None, partition_size=None, npartitions=None, selected_variables=None, **kwargs)#
Map a function over the partitions of the collection.
- Parameters:
func (PartitionCallable) – The function to apply to every partition of the collection.
*args – The positional arguments to pass to the function.
delayed (bool) – Whether to load the data lazily or not.
filters (str | Callable[[Dict[str, int]], bool] | None) – The predicate used to filter the partitions to process. To get more information on the predicate, see the documentation of the
partitions()
method.partition_size (int | None) – The length of each bag partition.
npartitions (int | None) – The number of desired bag partitions.
selected_variables (Sequence[str] | None) – A list of variables to retain from the collection. If None, all variables are kept.
**kwargs – The keyword arguments to pass to the function.
- Returns:
A bag containing the tuple of the partition scheme and the result of the function.
- Return type:
Example
>>> futures = collection.map( ... lambda x: (x["var1"] + x["var2"]).values) >>> for item in futures: ... print(item) [1.0, 2.0, 3.0, 4.0] [5.0, 6.0, 7.0, 8.0]