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

Function from_map

dask/dataframe/dask_expr/_collection.py:5736–5955  ·  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

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

Callers 5

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