title: calculate mean using 'year + month' combination in xarray
body: <p>I have a netcdf file with daily data for 5 years (2011 to 2015). I want to calculate monthly averages for the data using XArray in Python. </p>
  
  <pre><code>netcdf file:////test/Combined.nc {
    dimensions:
      latitude = 681;
      longitude = 841;
      time = 1826;
    variables:
      double latitude(latitude=681);
        :_FillValue = NaN; // double
        :name = "latitude";
        :long_name = "latitude";
        :units = "degrees_north";
        :standard_name = "latitude";
  
      double longitude(longitude=841);
        :_FillValue = NaN; // double
        :name = "longitude";
        :long_name = "longitude";
        :units = "degrees_east";
        :standard_name = "longitude";
  
      long time(time=1826);
        :name = "time";
        :long_name = "time";
        :standard_name = "time";
        :units = "days since 2011-01-01 00:00:00";
        :calendar = "proleptic_gregorian";
  
      float PET(time=1826, latitude=681, longitude=841);
        :_FillValue = -999.0f; // float
        :name = "PET";
        :long_name = "Potential evapotranspiration";
        :units = "mm";
        :standard_name = "PET";      
  
    :var_name = "PET";
  }
  </code></pre>
  
  <p>What I tried to do was was use groupby to calculate monthly averages:</p>
  
  <pre><code>import numpy as np
  import xarray as xr
  
  ds = xr.open_dataset("c:\\test\\Combined.nc")
  ds_avg = ds.PET.groupby('time.month').mean(dim='time')
  ds_avg.to_netcdf("C:\\test\\Combined_avg.nc") 
  </code></pre>
  
  <p>But the problem with above code is spits out a file with combined monthly average (from 2011 to 2015). That means i have 12 months in the result file. That is not what i want to do. I want to calculate the monthly average for January 2011, Feb 2011, March 2011 to Dec 2015 so that i get 12 * 5 months in the result file. So that means that the groupby should happen not on 'time.month' but 'time.year:time.month'. How do I do that?</p>
  
  <p>Thanks</p>