maxframe.liteframe.groupby.LiteFrameGroupBy.transform_chunk#

LiteFrameGroupBy.transform_chunk(func, *, dtypes=None, skip_infer=False, input_frame_type='pandas', args=(), **kwargs)#

GroupBy.transform_chunk() – per-group-chunk transform.

Applies func to each group’s execution chunk independently. As with the ungrouped transform_chunk, the output row count must match the input (transform semantics).

Parameters:
  • func (callable or callable class) –

    Function taking a per-group DataFrame chunk and returning a DataFrame with the same number of rows.

    If func is a class, it is instantiated once per group and close() (if defined) is always called at the end of each group.

  • dtypes (dict or pd.Series, optional) – Expected output dtypes.

  • skip_infer (bool, default False) – If True, skip dtype inference.

  • input_frame_type ({"pandas", "polars"}, default "pandas") – Frame type passed to func.

  • args (tuple) – Extra positional arguments forwarded to func.

  • **kwargs – Extra keyword arguments forwarded to func.

Returns:

Lazy LiteFrame with the same row count as the input, where each value is the per-group transform result. Call .execute() to materialize.

Return type:

LiteFrame

See also

groupby_transform

Per-group column transform.

groupby_apply_chunk

Per-group-chunk application.

Examples

>>> import maxframe.liteframe as mlf
>>> lf = mlf.LiteFrame({'key': ['a', 'a', 'b', 'b'], 'val': [1, 2, 3, 4]})

Scale each group’s chunk by 2 (row count preserved):

>>> result = lf.groupby('key').transform_chunk(lambda g: g * 2,
...                                            dtypes={'val': int})
>>> result.execute()
   val
0    2
1    4
2    6
3    8