title: How to slice a pandas dataframe based on unique values of a column inside a for loop and pass every slice to a function?
body: <p>Suppose I want to have a <code>for loop</code> which in its each iteration will slice  a big <code>pandas dataframe</code> <code>df</code> based on unique values of one of its columns lets say <code>A</code>, and then pass this sliced dataframe to a function which takes a dataframe as an argument lets say <code>fun(df)</code>. Basically <code>fun(df)</code> will get a new sliced dataframe with every iteration of for loop.
  For eg lets say following is my dataframe:</p>
  
  <pre><code>A    B    C    D
  1-1  an  at   23
  1-2  ab  can  34
  1-2  van bit  45
  1-2  vd  sun  23
  1-1  so  am   12
  ...
  </code></pre>
  
  <p>Now first iteration of for loop passes the below dataframe to <code>fun(df)</code></p>
  
  <pre><code>A    B    C    D
  1-1  an  at   23
  1-1  so  am   12
  </code></pre>
  
  <p>and next iteration will pass this one to <code>fun(df)</code></p>
  
  <pre><code>A    B    C    D
  1-2  ab  can  34
  1-2  van bit  45
  1-2  vd  sun  23
  </code></pre>
  
  <p>and so on and so forth.</p>
  
  <p>Number of iterations of for loop should be equal to the number of unique values of 'A'. Here in this case it will be 2.</p>
  
  <p>How can I do this in python? I am new to it and don't know how to proceed further.</p>