title: Extract Quarterly Data from Multi Quarter Periods
body: <p>Public companies in the US make quarterly filings (10-Q) and yearly filings (10-K). In most cases they will file three 10Qs per year and one 10K.</p>
  
  <p>In most cases, the quarterly filings (10Qs) contain quarterly data. For example, "revenue for the three months ending March 31, 2005."</p>
  
  <p>The yearly filings will often only have year end sums. For example: "revenue for the twelve months ending December 31, 2005."</p>
  
  <p>In order to get the value for Q4 of 2005, I need to take the yearly data and subtract the values for each of the quarters (Q1-Q3).</p>
  
  <p>In some cases, each of the quarterly data is expressed as year to date. For example, the first quarterly filing is "revenue for the three months ending March 31, 2005." The second is "revenue for the six months ending June 30, 2005." The third "revenue for the nine months ending September 30, 2005." The yearly is like above, "revenue for the twelve months ending December 31, 2005." This represents a generalization of the above issues in which the desire is to extract quarterly data which can be accomplished by repeated subtraction of the previous period data.</p>
  
  <p>My question is what is the best way in pandas to accomplish this quarterly data extraction?</p>
  
  <p>There a large number of fields (revenue, profit, exposes, etc) per period.</p>
  
  <p>A related question that I asked in regards to how to express this period data in pandas: <a href="https://stackoverflow.com/questions/17973156/creating-period-for-multi-quarter-timespan-in-pandas">Creating Period for Multi Quarter Timespan in Pandas</a></p>
  
  <p>Here is some example data of the first problem (three 10Qs and one 10K which only has year end data):</p>
  
  <p>10Q:</p>
  
  <ul>
  <li><a href="http://www.sec.gov/Archives/edgar/data/1174922/000119312512225309/d326512d10q.htm#tx326512_4" rel="nofollow noreferrer">http://www.sec.gov/Archives/edgar/data/1174922/000119312512225309/d326512d10q.htm#tx326512_4</a></li>
  <li><a href="http://www.sec.gov/Archives/edgar/data/1174922/000119312512347659/d360762d10q.htm#tx360762_3" rel="nofollow noreferrer">http://www.sec.gov/Archives/edgar/data/1174922/000119312512347659/d360762d10q.htm#tx360762_3</a></li>
  <li><a href="http://www.sec.gov/Archives/edgar/data/1174922/000119312512463380/d411552d10q.htm#tx411552_3" rel="nofollow noreferrer">http://www.sec.gov/Archives/edgar/data/1174922/000119312512463380/d411552d10q.htm#tx411552_3</a></li>
  </ul>
  
  <p>10K:</p>
  
  <ul>
  <li><a href="http://www.sec.gov/Archives/edgar/data/1174922/000119312513087674/d459372d10k.htm#tx459372_29" rel="nofollow noreferrer">http://www.sec.gov/Archives/edgar/data/1174922/000119312513087674/d459372d10k.htm#tx459372_29</a></li>
  </ul>
  
  <p>Calcbench refers to this problem: <a href="http://www.calcbench.com/Home/userGuide" rel="nofollow noreferrer">http://www.calcbench.com/Home/userGuide</a>: "Q4 calculation: Companies often do not report Q4 data, rather opting to report full year data instead. We’ll automatically calculate it for you. Data in blue is calculated.</p>
  
  <p>There will be multiple years of data and for each year I want to calculate the missing fourth quarter:</p>
  
  <pre><code>         2012Q2  2012Q3  2012Y  2013Q1  2013Q2  2013Q3  2013Y
  Revenue       1       1      1       1       1       1      1
  Expense      10      10     10      10      10      10     10
  </code></pre>