# xarray.DataArray.swap_dims

`DataArray.``swap_dims`(dims_dict: Mapping[Hashable, Hashable]) → xarray.core.dataarray.DataArray

  Returns a new DataArray with swapped dimensions.

  Parameters: | dims_dict (dict-like) – Dictionary whose keys are current dimension names and whose values are new names.
  Returns: | swapped – DataArray with swapped dimensions.
  Return type: | DataArray

  Examples

      >>> arr = xr.DataArray(data=[0, 1], dims="x",
                             coords={"x": ["a", "b"], "y": ("x", [0, 1])})
      >>> arr
      <xarray.DataArray (x: 2)>
      array([0, 1])
      Coordinates:
        * x        (x) <U1 'a' 'b'
          y        (x) int64 0 1
      >>> arr.swap_dims({"x": "y"})
      <xarray.DataArray (y: 2)>
      array([0, 1])
      Coordinates:
          x        (y) <U1 'a' 'b'
        * y        (y) int64 0 1
      >>> arr.swap_dims({"x": "z"})
      <xarray.DataArray (z: 2)>
      array([0, 1])
      Coordinates:
          x        (z) <U1 'a' 'b'
          y        (z) int64 0 1
      Dimensions without coordinates: z

  See also

  `DataArray.rename()`, `Dataset.swap_dims()`