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

Method transform

dask/dataframe/dask_expr/_groupby.py:2045–2080  ·  view source on GitHub ↗

Parallel version of pandas GroupBy.transform This mimics the pandas version except for the following: 1. If the grouper does not align with the index then this causes a full shuffle. The order of rows within each group may not be preserved. 2. Dask's GroupBy.

(self, func, meta=no_default, shuffle_method=None, *args, **kwargs)

Source from the content-addressed store, hash-verified

2043
2044 @insert_meta_param_description(pad=12)
2045 def transform(self, func, meta=no_default, shuffle_method=None, *args, **kwargs):
2046 """Parallel version of pandas GroupBy.transform
2047
2048 This mimics the pandas version except for the following:
2049
2050 1. If the grouper does not align with the index then this causes a full
2051 shuffle. The order of rows within each group may not be preserved.
2052 2. Dask's GroupBy.transform is not appropriate for aggregations. For custom
2053 aggregations, use :class:`dask.dataframe.groupby.Aggregation`.
2054
2055 .. warning::
2056
2057 Pandas' groupby-transform can be used to apply arbitrary functions,
2058 including aggregations that result in one row per group. Dask's
2059 groupby-transform will apply ``func`` once on each group, doing a shuffle
2060 if needed, such that each group is contained in one partition.
2061 When ``func`` is a reduction, e.g., you'll end up with one row
2062 per group. To apply a custom aggregation with Dask,
2063 use :class:`dask.dataframe.groupby.Aggregation`.
2064
2065 Parameters
2066 ----------
2067 func: function
2068 Function to apply
2069 args, kwargs : Scalar, Delayed or object
2070 Arguments and keywords to pass to the function.
2071 $META
2072
2073 Returns
2074 -------
2075 applied : Series or DataFrame depending on columns keyword
2076 """
2077 self._warn_if_no_meta(meta, method="transform")
2078 return self._transform_like_op(
2079 GroupByTransform, func, meta, shuffle_method, *args, **kwargs
2080 )
2081
2082 @insert_meta_param_description(pad=12)
2083 def shift(self, periods=1, meta=no_default, shuffle_method=None, *args, **kwargs):

Calls 2

_warn_if_no_metaMethod · 0.95
_transform_like_opMethod · 0.95