larray.LArray.append¶
-
LArray.append(axis, value, label=None)[source]¶ Adds an array to self along an axis.
The two arrays must have compatible axes.
Parameters: axis : axis reference
Axis along which to append input array (value).
value : scalar or LArray
Array with compatible axes.
label : str, optional
Label for the new item in axis
Returns: LArray
Array expanded with value along axis.
Examples
>>> a = ones('nat=BE,FO;sex=M,F') >>> a nat\sex M F BE 1.0 1.0 FO 1.0 1.0 >>> a.append(X.sex, a.sum(X.sex), 'M+F') nat\sex M F M+F BE 1.0 1.0 2.0 FO 1.0 1.0 2.0 >>> a.append(X.nat, 2, 'Other') nat\sex M F BE 1.0 1.0 FO 1.0 1.0 Other 2.0 2.0 >>> b = zeros('type=type1,type2') >>> b type type1 type2 0.0 0.0 >>> a.append(X.nat, b, 'Other') nat sex\type type1 type2 BE M 1.0 1.0 BE F 1.0 1.0 FO M 1.0 1.0 FO F 1.0 1.0 Other M 0.0 0.0 Other F 0.0 0.0