title: For loop equivalent to reduce execution time in pandas data frame operation
body: <p>I have written a for loop like this:</p>
  
  <pre><code>for i in newc2sdf.Source.unique():
      ydf=newc2sdf[newc2sdf.Source==i]
      for j in newc2sdf.Destination.unique():
          ydf1=ydf[ydf.Destination==j]
  </code></pre>
  
  <p>As I have so many unique records, It takes huge time to execute.</p>
  
  <p>I will do some basic operations from the ydf1 and it will return a single value and I will append the value in a list.</p>
  
  <p>And I want to calculate the sum of values from another column where the source and destinations will be unique.</p>
  
  <p>I have another column called timestamp (ex: 2016-08-01 00:10:01) and it's in numpy.datetime64 format, I want the sum of those where the timestamp will be 5 minutes more than the minimum timestamp for a particular source to destination.</p>
  
  <p>Is there any alternatives to reduce the execution time.</p>