title: How to expand dataframe with a calculated list based on rows in python
body: <p>I have that kind of data generated by this code</p>
  <pre><code>import pandas as pd
  
  def multichoose(n,k):
      if k &lt; 0 or n &lt; 0: return &quot;Error&quot;
      if not k: return [[0]*n]
      if not n: return []
      if n == 1: return [[k]]
      return [[0]+val for val in multichoose(n-1,k)] + \
          [[val[0]+1]+val[1:] for val in multichoose(n,k-1)]
  
  states=[]
  for i in range(0,3):
      states=states+multichoose(3,i)
  df_states = pd.DataFrame(states,columns=['x1','x2','x3'])
  df_states['cumsum']=df_states['x1']+df_states['x2']+df_states['x3']
  
  x1  x2  x3  cumsum
  0   0   0   0
  0   0   1   1
  0   1   0   1
  1   0   0   1
  0   0   2   2
  0   1   1   2
  0   2   0   2
  1   0   1   2
  1   1   0   2
  2   0   0   2
  </code></pre>
  <p>And I want to expand my data with this calculation</p>
  <pre><code># For example for the first row
  # in range of cumsum value + 2
  [[x, y] for x in range(df_states[['cumsum']].iloc[0][0]+2) for y in range(df_states[['cumsum']].iloc[0][0]+2)]
      
  #output
  [[0, 0], [0, 1], [1, 0], [1, 1]]
  </code></pre>
  <p>So my expected result is</p>
  <pre><code>
  x1  x2  x3  cumsum a1 a2
  0   0   0   0      0  0
  0   0   0   0      0  1
  0   0   0   0      1  0
  0   0   0   0      1  1
  0   0   1   1      0  0
  0   0   1   1      0  1
  0   0   1   1      0  2
  0   0   1   1      1  0
  0   0   1   1      1  1
  0   0   1   1      1  2
  0   0   1   1      2  0
  0   0   1   1      2  1
  0   0   1   1      2  2
  .   .   .   .      .  .
  .   .   .   .      .  .
  </code></pre>
  <p>And in the final result, I need to implement this expansion for all rows</p>
  <p>Thanks for help &lt;3</p>