maxframe.liteframe.LiteFrame.map#
- LiteFrame.map(func, *, na_action=None, dtype=None, skip_infer=False, args=(), **kwargs)#
Apply func element-wise to every value in the LiteFrame.
Each cell is transformed independently by
func; the output has the same shape and column names as the input. Output dtypes are inferred by mockingfuncon a sample value per column unlessdtypeis supplied orskip_inferis set.- Parameters:
func (callable or callable class) –
Function to apply to each element.
If
funcis a class, it is instantiated once per chunk,__call__is invoked per element, andclose()(if defined) is always called at the end of the chunk.na_action (str, optional) – If ‘ignore’, null values are propagated without calling func.
dtype (dtype, optional) – Output dtype applied to all columns.
skip_infer (bool) – If True, skip mock inference when dtype is not provided.
args (tuple) – Positional arguments forwarded to func.
**kwargs – Keyword arguments. ‘_check_output_dtype’ is popped for output validation; all others are forwarded to func.
- Returns:
Lazy LiteFrame with the same shape as the input, where each value is the result of applying
functo the corresponding input cell. Call.execute()to materialize.- Return type:
Examples
>>> import maxframe.liteframe as mlf >>> lf = mlf.LiteFrame({'a': [1, 2, 3], 'b': [10, 20, 30]}) >>> result = lf.map(lambda x: x * 2) >>> result.execute() a b 0 2 20 1 4 40 2 6 60
Specify an explicit output dtype with
dtype:>>> result = lf.map(lambda x: float(x), dtype='float64') >>> result.execute() a b 0 1.0 10.0 1 2.0 20.0 2 3.0 30.0