title: Compute annual mean of values from a tuple using time information
body: <p>I have daily precipitation values with time information in following form:</p>
  
  <pre><code>a = [(19500101,3.45),(19500102,1.2).......(19701231,1.4)]
  </code></pre>
  
  <p>I want to take annual mean of it using date information. It might be a simple solution. I have tried as below. Any suggestions?</p>
  
  <pre><code>prcp=numpy.array(precipitation)
  time=numpy.array(time)
  yearly=numpy.zeros(prcp.shape)
  
  #-----------------Get annual means-----------------
  for ii in xrange(len(time)):
      tt=time[ii]
      if ii==0:
          year_old=tt[0:4]
          index_start=ii
      else:
          #----------------new year----------------
          year=tt[0:4]
          if year != year_old:
              year_mean=numpy.mean(prcp[index_start:ii])
              yearly[index_start:ii]=year_mean
              year_old=month
              index_start=ii
  
      #----------------Get the last year----------------
      if ii==len(time)-1:
          year_mean=numpy.mean(prcp[index_start:])
          yearly[index_start:]=year_mean
  </code></pre>