# xarray.Variable.pad

#### Variable.pad(pad_width=None, mode='constant', stat_length=None, constant_values=None, end_values=None, reflect_type=None, keep_attrs=None, \*\*pad_width_kwargs)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/variable.py#L1469-L1567)

Return a new Variable with padded data.

* **Parameters:**
  * **pad_width** ([mapping](https://docs.python.org/3/glossary.html#term-mapping) of [hashable](../user-guide/terminology.html.md#term-name) to [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple) of [`int`](https://docs.python.org/3/builtins/functions.html#int)) – Mapping with the form of {dim: (pad_before, pad_after)}
    describing the number of values padded along each dimension.
    {dim: pad} is a shortcut for pad_before = pad_after = pad
  * **mode** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str), *default*: `"constant"`) – See numpy / Dask docs
  * **stat_length** ([`int`](https://docs.python.org/3/builtins/functions.html#int), [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple) or [mapping](https://docs.python.org/3/glossary.html#term-mapping) of [hashable](../user-guide/terminology.html.md#term-name) to [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)) – Used in ‘maximum’, ‘mean’, ‘median’, and ‘minimum’.  Number of
    values at edge of each axis used to calculate the statistic value.
  * **constant_values** ([scalar](../user-guide/terminology.html.md#term-scalar), [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple) or [mapping](https://docs.python.org/3/glossary.html#term-mapping) of [hashable](../user-guide/terminology.html.md#term-name) to [scalar](../user-guide/terminology.html.md#term-scalar) or [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)) – Used in ‘constant’.  The values to set the padded values for each
    axis.
  * **end_values** ([scalar](../user-guide/terminology.html.md#term-scalar), [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple) or [mapping](https://docs.python.org/3/glossary.html#term-mapping) of [hashable](../user-guide/terminology.html.md#term-name) to [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)) – Used in ‘linear_ramp’.  The values used for the ending value of the
    linear_ramp and that will form the edge of the padded array.
  * **reflect_type** (`{"even", "odd"}`, *optional*) – Used in “reflect”, and “symmetric”.  The “even” style is the
    default with an unaltered reflection around the edge value.  For
    the “odd” style, the extended part of the array is created by
    subtracting the reflected values from two times the edge value.
  * **keep_attrs** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), *optional*) – If True, the variable’s attributes (attrs) will be copied from
    the original object to the new one.  If False (default), the new
    object will be returned without attributes.
  * **\*\*pad_width_kwargs** – One of pad_width or pad_width_kwargs must be provided.
* **Returns:**
  **padded** ([`Variable`](xarray.Variable.html.md#xarray.Variable)) – Variable with the same dimensions and attributes but padded data.
