title: Python Pandas Dataframe year over year comparison
body: <p>I'm a newbie at Pandas but have a very strong SQL background.  I actually know how to do this both in Excel and SQL but would like to see how to do this in Pandas to help me learn.  I tried reading ahead in 'Python for Data Analysis' and I'm 1/2 a Coursera course into Pandas but this is well beyond my skill set.</p>
  
  <p>What I would like to see how to do in Pandas is a Year over Year variation of how much time it took us to make certain parts for our customers.</p>
  
  <p>The output would look like this:</p>
  
  <pre><code>Year  Shipped_Part_No  Shipped_Part_Rev  Labor_Hours       Gross Margin
                                          Min Max Avg Sdev   Min Max Avg Sdev
  2013  Widget1           AM              0   3   2.1  1.8  -.18  .1  .18  .18
  2014  Widget1           AM              2   7   2.9  1.2  -.1   .2  .28  .11
  2015  Widget1           AM              1   2   2.2  1.4  -.13  .3  .81  .12
  </code></pre>
  
  <p>As far as I can tell I need to set the index to be both ['Shipped_Part_No'] and ['Shipped_Part_Rev'] and then do some grouping and run some aggregate functions.</p>
  
  <p>I'm open to any pointers on how to think about this or display it for better readability - my mind is so SQL focused I'm having a hard time seeing how to use a data-frame to accomplish it.</p>
  
  <p>I have a CSV output file from a SQL query I wrote, the file is here:</p>
  
  <p><a href="https://drive.google.com/open?id=0B4xdnV0LFZI1czBUT19YanVPNFk" rel="nofollow noreferrer">https://drive.google.com/open?id=0B4xdnV0LFZI1czBUT19YanVPNFk</a></p>
  
  <p>Usually I would post some code of what I've at least tried but it all keeps failing, so I think it's unhelpful.</p>
  
  <p>I'm running Anaconda with Python 3.5 on a Windows PC.</p>