MCPcopy Create free account
hub / github.com/dask/dask / from_map

Function from_map

dask/dataframe/dask_expr/_collection.py:5733–5952  ·  view source on GitHub ↗

Create a DataFrame collection from a custom function map. ``from_map`` is the preferred option when reading from data sources that are not natively supported by Dask or if the data source requires custom handling before handing things of to Dask DataFrames. Examples are things like

(
    func,
    *iterables,
    args=None,
    meta=no_default,
    divisions=None,
    label=None,
    enforce_metadata=False,
    **kwargs,
)

Source from the content-addressed store, hash-verified

5731
5732
5733def from_map(
5734 func,
5735 *iterables,
5736 args=None,
5737 meta=no_default,
5738 divisions=None,
5739 label=None,
5740 enforce_metadata=False,
5741 **kwargs,
5742):
5743 """Create a DataFrame collection from a custom function map.
5744
5745 ``from_map`` is the preferred option when reading from data sources
5746 that are not natively supported by Dask or if the data source
5747 requires custom handling before handing things of to Dask DataFrames.
5748 Examples are things like binary files or other unstructured data that
5749 doesn't have an IO connector.
5750
5751 ``from_map`` supports column projection by the optimizer. The optimizer
5752 tries to push column selections into the from_map call if the function
5753 supports a ``columns`` argument.
5754
5755 Parameters
5756 ----------
5757 func : callable
5758 Function used to create each partition. Column projection will be
5759 enabled if the function has a ``columns`` keyword argument.
5760 *iterables : Iterable objects
5761 Iterable objects to map to each output partition. All iterables must
5762 be the same length. This length determines the number of partitions
5763 in the output collection (only one element of each iterable will
5764 be passed to ``func`` for each partition).
5765 args : list or tuple, optional
5766 Positional arguments to broadcast to each output partition. Note
5767 that these arguments will always be passed to ``func`` after the
5768 ``iterables`` positional arguments.
5769 $META
5770 divisions : tuple, str, optional
5771 Partition boundaries along the index.
5772 For tuple, see https://docs.dask.org/en/latest/dataframe-design.html#partitions
5773 For string 'sorted' will compute the delayed values to find index
5774 values. Assumes that the indexes are mutually sorted.
5775 If None, then won't use index information
5776 label : str, optional
5777 String to use as the function-name label in the output
5778 collection-key names.
5779 token : str, optional
5780 String to use as the "token" in the output collection-key names.
5781 enforce_metadata : bool, default True
5782 Whether to enforce at runtime that the structure of the DataFrame
5783 produced by ``func`` actually matches the structure of ``meta``.
5784 This will rename and reorder columns for each partition,
5785 and will raise an error if this doesn't work,
5786 but it won't raise if dtypes don't match.
5787 **kwargs:
5788 Key-word arguments to broadcast to each output partition. These
5789 same arguments will be passed to ``func`` for every output partition.
5790

Callers 4

test_from_mapFunction · 0.90
with_specFunction · 0.90

Calls 8

new_collectionFunction · 0.90
FromMapProjectableClass · 0.90
FromMapClass · 0.90
pyarrow_strings_enabledFunction · 0.90
setClass · 0.85
popMethod · 0.80
addMethod · 0.45
getMethod · 0.45

Tested by 3

test_from_mapFunction · 0.72