cf.Data.pad_missing

Data.pad_missing(axis, pad_width=None, to_size=None, inplace=False)[source]

Pad an axis with missing data.

Parameters
axis: int

Select the axis for which the padding is to be applied.

Parameter example:

Pad second axis: axis=1.

Parameter example:

Pad the last axis: axis=-1.

pad_width: sequence of int, optional

Number of values to pad before and after the edges of the axis.

to_size: int, optional

Pad the axis after so that the new axis has the given size.

inplace: bool, optional

If True then do the operation in-place and return None.

Returns
Data or None

The padded data, or None if the operation was in-place.

Examples

>>> d = cf.Data(np.arange(6).reshape(2, 3))
>>> print(d.array)
[[0 1 2]
 [3 4 5]]
>>> e = d.pad_missing(1, (1, 2))
>>> print(e.array)
[[-- 0 1 2 -- --]
 [-- 3 4 5 -- --]]
>>> f = e.pad_missing(0, (0, 1))
>>> print(f.array)
[[--  0  1  2 -- --]
 [--  3  4  5 -- --]
 [-- -- -- -- -- --]]
>>> g = d.pad_missing(1, to_size=5)
>>> print(g.array)
[[0 1 2 -- --]
 [3 4 5 -- --]]