title: How to assign the multiple values of an output to new multiple columns of a dataframe?
body: <p>I have the following function:</p>
  
  <pre><code>def sum(x):
      oneS = x.iloc[0:len(x)//10].agg('sum')
      twoS = x.iloc[len(x)//10:2*len(x)//10].agg('sum')
      threeS = x.iloc[2*len(x)//10:3*len(x)//10].agg('sum')
      fourS = x.iloc[3*len(x)//10:4*len(x)//10].agg('sum')
      fiveS = x.iloc[4*len(x)//10:5*len(x)//10].agg('sum')
      sixS = x.iloc[5*len(x)//10:6*len(x)//10].agg('sum')
      sevenS = x.iloc[6*len(x)//10:7*len(x)//10].agg('sum')
      eightS = x.iloc[7*len(x)//10:8*len(x)//10].agg('sum')
      nineS = x.iloc[8*len(x)//10:9*len(x)//10].agg('sum')
      tenS = x.iloc[9*len(x)//10:len(x)//10].agg('sum')
      return [oneS,twoS,threeS,fourS,fiveS,sixS,sevenS,eightS,nineS,tenS]
  </code></pre>
  
  <p>How to assign the outputs of this function to columns of dataframe (which already exists)</p>
  
  <p>The dataframe I am applying the function is as below</p>
  
  <pre><code>Cycle   Type    Time
  1   1   101
  1   1   102
  1   1   103
  1   1   104
  1   1   105
  1   1   106
  9   1   101
  9   1   102
  9   1   103
  9   1   104
  9   1   105
  9   1   106
  </code></pre>
  
  <p>The dataframe I want to add the columns is something like below &amp; the new columns Ones, TwoS..... Should be added like shown &amp; filled with the results of the function.</p>
  
  <pre><code>Cycle   Type    OneS    TwoS    ThreeS
  1   1           
  9   1           
  8   1           
  10  1           
  3   1           
  5   2           
  6   2           
  7   2           
  </code></pre>
  
  <p>If I write a function for just one value and apply it like the following, it is possible:</p>
  
  <pre><code>grouped_data['fm']= data_train_bel1800.groupby(['Cycle', 'Type'])['Time'].apply( lambda x: fm(x))
  </code></pre>
  
  <p>But I want to do it all at once so that it is neat and clear.</p>