title: How do I apply a lambda function on pandas slices, and return the same format as the input data frame?
body: <p>I want to apply a function  to row slices of dataframe in pandas for each row and returning a dataframe with for each row the value and number of slices that was calculated. 
  So, for example</p>
  
  <pre><code>df = pandas.DataFrame(numpy.round(numpy.random.normal(size=(2, 10)),2))
  f = lambda x: (x - x.mean())
  </code></pre>
  
  <p>What I want is to apply lambda function f from column 0 to 5 and from column 5 to 10.
  I did this:</p>
  
  <pre><code>a = pandas.DataFrame(f(df.T.iloc[0:5,:])
  </code></pre>
  
  <p>but this is only for the first slice.. how can include the second slice in the code, so that my resulting output frame looks exactly as the input frame -- just that every data point is changed to its value minus the mean of the corresponding slice.</p>
  
  <p>I hope it makes sense.. What would be the right way to go with this? </p>
  
  <p>thank you.</p>