title: Remove a dimension from some variables in an xarray Dataset
body: <p>I have an xarray Dataset where some variables have more dimensions than necessary (e.g., a 3D dataset where the "latitude" and "longitude" variables also vary along time). How do I remove the extra dimensions?</p>
  
  <p>For example, in the dataset below, 'bar' is a 2D variable along the <code>x</code> and <code>y</code> axes, with constant values along the <code>x</code> axis. How do I remove the <code>x</code> dimension from 'bar' but not 'foo'?</p>
  
  <pre><code>&gt;&gt;&gt; ds = xr.Dataset({'foo': (('x', 'y'), np.random.randn(2, 3))},
                      {'x': [1, 2], 'y': [1, 2, 3],
                       'bar': (('x', 'y'), [[4, 5, 6], [4, 5, 6]])})
  &gt;&gt;&gt; ds
  &lt;xarray.Dataset&gt;
  Dimensions:  (x: 2, y: 3)
  Coordinates:
    * x        (x) int64 1 2
    * y        (y) int64 1 2 3
      bar      (x, y) int64 4 5 6 4 5 6
  Data variables:
      foo      (x, y) float64 -0.9595 0.6704 -1.047 0.9948 0.8241 1.643
  </code></pre>