pad

sparse.pad(array, pad_width, mode='constant', **kwargs)[source]

Performs the equivalent of numpy.pad for SparseArray. Note that this function returns a new array instead of a view.

Parameters:
  • array (SparseArray) – Sparse array which is to be padded.

  • pad_width ({sequence, array_like, int}) – Number of values padded to the edges of each axis. ((before_1, after_1), … (before_N, after_N)) unique pad widths for each axis. ((before, after),) yields same before and after pad for each axis. (pad,) or int is a shortcut for before = after = pad width for all axes.

  • mode (str) – Pads to a constant value which is fill value. Currently only constant mode is implemented

  • constant_values (int) – The values to set the padded values for each axis. Default is 0. This must be same as fill value.

Returns:

The padded sparse array.

Return type:

SparseArray

Raises:

See also

numpy.pad

NumPy equivalent function