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

Method map_overlap

dask/dataframe/dask_expr/_collection.py:1132–1286  ·  view source on GitHub ↗

Apply a function to each partition, sharing rows with adjacent partitions. This can be useful for implementing windowing functions such as ``df.rolling(...).mean()`` or ``df.diff()``. Parameters ---------- func : function Function applied to each

(
        self,
        func,
        before,
        after,
        *args,
        meta=no_default,
        enforce_metadata=True,
        transform_divisions=True,
        clear_divisions=False,
        align_dataframes=False,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

1130
1131 @insert_meta_param_description(pad=12)
1132 def map_overlap(
1133 self,
1134 func,
1135 before,
1136 after,
1137 *args,
1138 meta=no_default,
1139 enforce_metadata=True,
1140 transform_divisions=True,
1141 clear_divisions=False,
1142 align_dataframes=False,
1143 **kwargs,
1144 ):
1145 """Apply a function to each partition, sharing rows with adjacent partitions.
1146
1147 This can be useful for implementing windowing functions such as
1148 ``df.rolling(...).mean()`` or ``df.diff()``.
1149
1150 Parameters
1151 ----------
1152 func : function
1153 Function applied to each partition.
1154 before : int, timedelta or string timedelta
1155 The rows to prepend to partition ``i`` from the end of
1156 partition ``i - 1``.
1157 after : int, timedelta or string timedelta
1158 The rows to append to partition ``i`` from the beginning
1159 of partition ``i + 1``.
1160 args, kwargs :
1161 Positional and keyword arguments to pass to the function.
1162 Positional arguments are computed on a per-partition basis, while
1163 keyword arguments are shared across all partitions. The partition
1164 itself will be the first positional argument, with all other
1165 arguments passed *after*. Arguments can be ``Scalar``, ``Delayed``,
1166 or regular Python objects. DataFrame-like args (both dask and
1167 pandas) will be repartitioned to align (if necessary) before
1168 applying the function; see ``align_dataframes`` to control this
1169 behavior.
1170 enforce_metadata : bool, default True
1171 Whether to enforce at runtime that the structure of the DataFrame
1172 produced by ``func`` actually matches the structure of ``meta``.
1173 This will rename and reorder columns for each partition,
1174 and will raise an error if this doesn't work,
1175 but it won't raise if dtypes don't match.
1176 transform_divisions : bool, default True
1177 Whether to apply the function onto the divisions and apply those
1178 transformed divisions to the output.
1179 align_dataframes : bool, default True
1180 Whether to repartition DataFrame- or Series-like args
1181 (both dask and pandas) so their divisions align before applying
1182 the function. This requires all inputs to have known divisions.
1183 Single-partition inputs will be split into multiple partitions.
1184
1185 If False, all inputs must have either the same number of partitions
1186 or a single partition. Single-partition inputs will be broadcast to
1187 every partition of multi-partition inputs.
1188 $META
1189

Callers 11

test_map_overlapFunction · 0.45
test_map_overlap_raisesFunction · 0.45
test_map_overlap_errorsFunction · 0.45
test_map_overlapFunction · 0.45
test_map_overlap_namesFunction · 0.45
test_map_overlap_errorsFunction · 0.45
test_time_rollingFunction · 0.45

Calls 1

map_overlapFunction · 0.70

Tested by 11

test_map_overlapFunction · 0.36
test_map_overlap_raisesFunction · 0.36
test_map_overlap_errorsFunction · 0.36
test_map_overlapFunction · 0.36
test_map_overlap_namesFunction · 0.36
test_map_overlap_errorsFunction · 0.36
test_time_rollingFunction · 0.36