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

Function _get_meta_map_partitions

dask/dataframe/dask_expr/_expr.py:4159–4193  ·  view source on GitHub ↗

Helper to generate metadata for map_partitions and map_overlap output.

(args, dfs, func, kwargs, meta, parent_meta)

Source from the content-addressed store, hash-verified

4157
4158
4159def _get_meta_map_partitions(args, dfs, func, kwargs, meta, parent_meta):
4160 """
4161 Helper to generate metadata for map_partitions and map_overlap output.
4162 """
4163 meta_index = getattr(make_meta(dfs[0]), "index", None) if dfs else None
4164 if parent_meta is None and dfs:
4165 parent_meta = dfs[0]._meta
4166 if meta is no_default:
4167 # Use non-normalized kwargs here, as we want the real values (not
4168 # delayed values)
4169 a = [meta_nonempty(arg._meta) if isinstance(arg, Expr) else arg for arg in args]
4170 meta = emulate(func, *a, udf=True, **kwargs)
4171 meta_is_emulated = True
4172 else:
4173 meta = make_meta(meta, index=meta_index, parent_meta=parent_meta)
4174 meta_is_emulated = False
4175
4176 if not (has_parallel_type(meta) or is_arraylike(meta) and meta.shape) and not all(
4177 isinstance(arg, Expr) and arg.ndim == 0 for arg in args
4178 ):
4179 if not meta_is_emulated:
4180 warnings.warn(
4181 "Meta is not valid, `map_partitions` and `map_overlap` expects output to be a pandas object. "
4182 "Try passing a pandas object as meta or a dict or tuple representing the "
4183 "(name, dtype) of the columns. In the future the meta you passed will not work.",
4184 FutureWarning,
4185 )
4186 # If `meta` is not a pandas object, the concatenated results will be a
4187 # different type
4188 meta = make_meta(_concat([meta]), index=meta_index)
4189
4190 # Ensure meta is empty series
4191 meta = make_meta(meta, parent_meta=parent_meta)
4192
4193 return meta
4194
4195
4196from dask.dataframe.dask_expr._reductions import (

Callers 3

_metaMethod · 0.85
_metaMethod · 0.85
_metaMethod · 0.85

Calls 6

make_metaFunction · 0.90
has_parallel_typeFunction · 0.90
is_arraylikeFunction · 0.90
_concatFunction · 0.90
emulateFunction · 0.85
allFunction · 0.85

Tested by

no test coverage detected