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

Function from_map

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

5805
5806
5807def from_map(
5808 func,
5809 *iterables,
5810 args=None,
5811 meta=no_default,
5812 divisions=None,
5813 label=None,
5814 enforce_metadata=False,
5815 **kwargs,
5816):
5817 """Create a DataFrame collection from a custom function map.
5818
5819 ``from_map`` is the preferred option when reading from data sources
5820 that are not natively supported by Dask or if the data source
5821 requires custom handling before handing things of to Dask DataFrames.
5822 Examples are things like binary files or other unstructured data that
5823 doesn't have an IO connector.
5824
5825 ``from_map`` supports column projection by the optimizer. The optimizer
5826 tries to push column selections into the from_map call if the function
5827 supports a ``columns`` argument.
5828
5829 Parameters
5830 ----------
5831 func : callable
5832 Function used to create each partition. Column projection will be
5833 enabled if the function has a ``columns`` keyword argument.
5834 *iterables : Iterable objects
5835 Iterable objects to map to each output partition. All iterables must
5836 be the same length. This length determines the number of partitions
5837 in the output collection (only one element of each iterable will
5838 be passed to ``func`` for each partition).
5839 args : list or tuple, optional
5840 Positional arguments to broadcast to each output partition. Note
5841 that these arguments will always be passed to ``func`` after the
5842 ``iterables`` positional arguments.
5843 $META
5844 divisions : tuple, str, optional
5845 Partition boundaries along the index.
5846 For tuple, see https://docs.dask.org/en/latest/dataframe-design.html#partitions
5847 For string 'sorted' will compute the delayed values to find index
5848 values. Assumes that the indexes are mutually sorted.
5849 If None, then won't use index information
5850 label : str, optional
5851 String to use as the function-name label in the output
5852 collection-key names.
5853 token : str, optional
5854 String to use as the "token" in the output collection-key names.
5855 enforce_metadata : bool, default True
5856 Whether to enforce at runtime that the structure of the DataFrame
5857 produced by ``func`` actually matches the structure of ``meta``.
5858 This will rename and reorder columns for each partition,
5859 and will raise an error if this doesn't work,
5860 but it won't raise if dtypes don't match.
5861 **kwargs:
5862 Key-word arguments to broadcast to each output partition. These
5863 same arguments will be passed to ``func`` for every output partition.
5864

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