title: Using Python's Pandas to find average values by bins
body: <p>I just started using pandas to analyze groundwater well data over time.</p>
  
  <p>My data in a text file looks like (site_no, date, well_level):</p>
  
  <pre><code>485438103132901 19800417    -7.1
  
  485438103132901 19800506    -6.8
  
  483622101085001 19790910    -6.7
  
  485438103132901 19790731    -6.2
  
  483845101112801 19801111    -5.37
  
  484123101124601 19801111    -5.3
  
  485438103132901 19770706    -4.98
  </code></pre>
  
  <p>I would like an output with average well levels binned by 5 year increments and with a count:</p>
  
  <pre><code>site_no   avg 1960-end1964  count    avg 1965-end1969  count    avg 1970-end1974 count
  </code></pre>
  
  <p>I am reading in the data with:</p>
  
  <pre><code>names = ['site_no','date','wtr_lvl']
  df = pd.read_csv('D:\info.txt', sep='\t',names=names)
  </code></pre>
  
  <p>I can find the overall average by site with:</p>
  
  <pre><code>avg = df.groupby(['site_no'])['wtr_lvl'].mean().reset_index()
  </code></pre>
  
  <p>My crude bin attempts use:</p>
  
  <pre><code>a1 = df[df.date &gt; 19600000]
  a2 = a1[a1.date &lt; 19650000]
  avga2 = a2.groupby(['site_no'])['wtr_lvl'].mean()
  </code></pre>
  
  <p>My question: how can I join the results to display as desired?  I tried merge, join, and append, but they do not allow for empty data frames (which happens).  Also, I am sure there is a simple way to bin the data by the dates.  Thanks.</p>