title: Integrating over similar indices in pandas dataframe
body: <p>I am having some trouble looping an integral over a pandas dataframe. Here is an example of the CSV I am working with:</p>
  
  <p>NAME,Int,K,Z</p>
  
  <p>A,0,12,50</p>
  
  <p>A,1,34,50</p>
  
  <p>A,2,47,35</p>
  
  <p>A,3,19,31</p>
  
  <p>B,0,25,28</p>
  
  <p>B,1,8,3</p>
  
  <p>B,2,4,27</p>
  
  <p>B,3,18,10</p>
  
  <p>C,0,14,15</p>
  
  <p>C,1,10,19</p>
  
  <p>C,2,46,1</p>
  
  <p>C,3,19,41</p>
  
  <p>Here is the loop I am trying:</p>
  
  <pre><code>def integral(DF):
  
      for i in DF.loc[:]:
  
         integral=integrate.trapz(y=DF.loc[i]['K'],x=DF.loc[i]['Int'],dx=1)
  
      return DF.loc[i] and integral
  </code></pre>
  
  <p>Keeps returning an error saying the column next to the index column,"NAME", is not in the index. Any help would be appreciated. To clarify, I am trying to take the integrals of the K &amp; Z columns with "Int" being the x-axis and return both name and integral. My actual CSV is much larger than this.</p>