# xarray.Dataset.swap_dims

`Dataset.``swap_dims`(dims_dict: Mapping[Hashable, Hashable], inplace: bool = None) → xarray.core.dataset.Dataset

  Returns a new object with swapped dimensions.

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

  Examples

      >>> ds = xr.Dataset(data_vars={"a": ("x", [5, 7]), "b": ("x", [0.1, 2.4])},
                          coords={"x": ["a", "b"], "y": ("x", [0, 1])})
      >>> ds
      <xarray.Dataset>
      Dimensions:  (x: 2)
      Coordinates:
        * x        (x) <U1 'a' 'b'
          y        (x) int64 0 1
      Data variables:
          a        (x) int64 5 7
          b        (x) float64 0.1 2.4
      >>> ds.swap_dims({"x": "y"})
      <xarray.Dataset>
      Dimensions:  (y: 2)
      Coordinates:
          x        (y) <U1 'a' 'b'
        * y        (y) int64 0 1
      Data variables:
          a        (y) int64 5 7
          b        (y) float64 0.1 2.4
      >>> ds.swap_dims({"x": "z"})
      <xarray.Dataset>
      Dimensions:  (z: 2)
      Coordinates:
          x        (z) <U1 'a' 'b'
          y        (z) int64 0 1
      Dimensions without coordinates: z
      Data variables:
          a        (z) int64 5 7
          b        (z) float64 0.1 2.4

  See also

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