larray.Array.append

Array.append(self, 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 value.

value : scalar or Array

Scalar or array with compatible axes.

label : scalar, optional

Label for the new item in axis

Returns:
Array

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('sex', a.sum('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('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('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