title: Understanding xarray groupby
body: <p>I am trying to count the number of members in each group, akin to <code>pandas.DataFrame.groupby.count</code>. However, it doesn't seem to be working. Here is an example:</p>
  
  <pre><code>In [1]: xr_test = xr.DataArray(np.random.rand(6), coords=[[10,10,11,12,12,12]], dims=['dim0'])
          xr_test
  Out[1]: &lt;xarray.DataArray (dim0: 6)&gt;
          array([ 0.92908804,  0.15495709,  0.85304435,  0.24039265,  0.3755476 ,
                  0.29261274])
          Coordinates:
            * dim0     (dim0) int32 10 10 11 12 12 12
  
  In [2]: xr_test.groupby('dim0').count()
  Out[2]: &lt;xarray.DataArray (dim0: 6)&gt;
          array([1, 1, 1, 1, 1, 1])
          Coordinates:
            * dim0     (dim0) int32 10 10 11 12 12 12
  </code></pre>
  
  <p>However, I expect this output:</p>
  
  <pre><code>Out[2]: &lt;xarray.DataArray (dim0: 3)&gt;
          array([2, 1, 3])
          Coordinates:
            * dim0     (dim0) int32 10 11 12
  </code></pre>
  
  <p>What's going on?</p>
  
  <p>In other words:</p>
  
  <pre><code>In [3]: xr_test.to_series().groupby(level=0).count()
  Out[3]: dim0
          10    2
          11    1
          12    3
          dtype: int64
  </code></pre>