title: How to calculate monthly annual average from daily dataframe and plot it by abbreviated month
body: <p>I have daily values of precipitation and temperature for a period of several years. I would like to compute the average of the precipitation and temperature for each month of the year (January to December). For precipitation I first need to calculate the summation of daily precipitation for each month, and then compute the average for the same month for all the years of data. For temperature I need to average the monthly averages of the values (so an average of all the data for all the months gives the exact same result). Once this is done I need to plot both sets of data (precipitation and temperature) using abbreviated months.</p>
  <p>I cannot find a way to compute the precipitation values and to be able to obtain the sum for each month and to then average it for all years. Furthermore, I am having trouble to display the format in abbreviated months.</p>
  <p>This is what I have tried so far (unsuccessfully):</p>
  <pre><code>import pandas as pd
  
  import matplotlib.pyplot as plt
  from matplotlib.dates import DateFormatter
  
  example = [['01.10.1965 00:00', 13.88099957,    5.375],
      ['02.10.1965 00:00',    5.802999973,    3.154999971],
      ['03.10.1965 00:00',    9.605699539,    0.564999998],
      ['14.10.1965 00:00',    0.410299987,    1.11500001],
      ['31.10.1965 00:00',    6.184500217,    -0.935000002],
      ['01.11.1965 00:00',    0.347299993,    -5.235000134],
      ['02.11.1965 00:00',    0.158299997,    -8.244999886],
      ['03.11.1965 00:00',    1.626199961,    -3.980000019],
      ['24.10.1966 00:00',    0,              3.88499999],
      ['25.10.1966 00:00',    0.055100001,    1.279999971],
      ['30.10.1966 00:00',    0.25940001,     -5.554999828]]
  
  names = [&quot;date&quot;,&quot;Pobs&quot;,&quot;Tobs&quot;]
  data = pd.DataFrame(example, columns=names)
  data['date'] = pd.to_datetime(data['date'], format='%d.%m.%Y %H:%M')
  
  #I think the average of temperature is well computed but the precipitation would give the complete summation for all years!
  tempT = data.groupby([data['date'].dt.month_name()], sort=False).mean().eval('Tobs')
  tempP = data.groupby([data['date'].dt.month_name()], sort=False).sum().eval('Pobs') 
  
  fig = plt.figure(); ax1 = fig.add_subplot(1,1,1); ax2 = ax1.twinx();
  ax1.bar(tempP.index.tolist(), tempP.values, color='blue')
  ax2.plot(tempT.index.tolist(), tempT.values, color='red')
  ax1.set_ylabel('Precipitation [mm]', fontsize=10)
  ax2.set_ylabel('Temperature [°C]', fontsize=10) 
  #ax1.xaxis.set_major_formatter(DateFormatter(&quot;%b&quot;)) #this line does not work properly!
  plt.show()
  </code></pre>