MCPcopy
hub / github.com/dask/dask / make_meta

Function make_meta

dask/dataframe/dispatch.py:95–135  ·  view source on GitHub ↗

This method creates meta-data based on the type of ``x``, and ``parent_meta`` if supplied. Parameters ---------- x : Object of any type. Object to construct meta-data from. index : Index, optional Any index to use in the metadata. This is a pass-through

(x, index=None, parent_meta=None)

Source from the content-addressed store, hash-verified

93
94
95def make_meta(x, index=None, parent_meta=None):
96 """
97 This method creates meta-data based on the type of ``x``,
98 and ``parent_meta`` if supplied.
99
100 Parameters
101 ----------
102 x : Object of any type.
103 Object to construct meta-data from.
104 index : Index, optional
105 Any index to use in the metadata. This is a pass-through
106 parameter to dispatches registered.
107 parent_meta : Object, default None
108 If ``x`` is of arbitrary types and thus Dask cannot determine
109 which back-end to be used to generate the meta-data for this
110 object type, in which case ``parent_meta`` will be used to
111 determine which back-end to select and dispatch to. To
112 utilize this parameter ``make_meta_obj`` has be dispatched.
113 If ``parent_meta`` is ``None``, a pandas DataFrame is used for
114 ``parent_meta`` that chooses pandas as the backend.
115
116 Returns
117 -------
118 A valid meta-data
119 """
120
121 if not isinstance(x, (pd.Series, pd.DataFrame, pd.Index)) and hasattr(x, "_meta"):
122 if is_dask_collection(x):
123 return x._meta
124
125 try:
126 return make_meta_dispatch(x, index=index)
127 except TypeError:
128 if parent_meta is not None:
129 func = make_meta_obj.dispatch(type(parent_meta))
130 return func(x, index=index)
131 else:
132 # Default to using the pandas backend
133 # if ``parent_meta`` is not specified
134 func = make_meta_obj.dispatch(pd.DataFrame)
135 return func(x, index=index)
136
137
138def union_categoricals(to_union, sort_categories=False, ignore_order=False):

Callers 15

_empty_seriesFunction · 0.90
_metaMethod · 0.90
_metaMethod · 0.90
_metaMethod · 0.90
_metaMethod · 0.90
_metaMethod · 0.90
_metaMethod · 0.90
_meta_apply_transformFunction · 0.90
_metaMethod · 0.90
_metaMethod · 0.90
_metaMethod · 0.90
_metaMethod · 0.90

Calls 3

is_dask_collectionFunction · 0.90
funcFunction · 0.70
dispatchMethod · 0.45

Tested by 2

test_make_metaFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…