maxframe.dataframe.Series.transform#
- Series.transform(func, convert_dtype=True, axis=0, *args, skip_infer=False, dtype=None, **kwargs)#
在自身上调用
func以生成一个包含转换值的 Series。生成的 Series 将具有与自身相同的轴长度。
- 参数:
function (-)
either (must)
Series.apply. (work when passed a Series or when passed to)
are (Accepted combinations)
function
name (- string function)
names (- list of functions and/or function)
'sqrt'] (e.g. [np.exp.)
functions (- dict of axis labels ->)
such. (function names or list of)
axis ({0 or 'index'}) -- 为与 DataFrame 兼容而需要的参数。
dtype (numpy.dtype, default None) -- 指定返回的 DataFrames 的数据类型。详见“说明”部分。
skip_infer (bool, default False) -- 当未指定 dtypes 或 output_type 时是否推断数据类型。
*args -- 传递给 func 的位置参数。
**kwargs -- 传递给 func 的关键字参数。
- 返回:
系列
必须与自身具有相同长度的 Series。
:raises ValueError : 如果返回的 Series 与自身的长度不同:
参见
Series.agg仅执行聚合类型的操作。
Series.apply在 Series 上调用函数。
备注
在确定输出数据类型和返回值形状时,MaxFrame 会尝试将
func应用于一个模拟 Series,此时 transform 调用可能会失败。发生这种情况时,您需要指定输出 Series 的dtype。示例
>>> import maxframe.tensor as mt >>> import maxframe.dataframe as md >>> df = md.DataFrame({'A': range(3), 'B': range(1, 4)}) >>> df.execute() A B 0 0 1 1 1 2 2 2 3 >>> df.transform(lambda x: x + 1).execute() A B 0 1 2 1 2 3 2 3 4