title: Create DataFrame with a loop-based numpy array
body: <p>I am doing an for loop in order to compute statistical values. For this, I'm storing the computations from a column in different variables (D10, D50 and D90).</p>
  <p>Then I store them in an array called result</p>
  <pre class="lang-python prettyprint-override"><code># First created an empty numpy array
  
  result_array = np.array([])
  
  for column in df:
      
      # just computations you can ignore them
  
      df = df.sort_values('Size')
      
      cumul = df[column].cumsum()
      
      suma_de_frecuencias = df[column].sum()
      
      D10 = sum(cumul &lt; 0.1 * float(suma_de_frecuencias))
      
      D50 = sum(cumul &lt; 0.5 * float(suma_de_frecuencias))
      
      D90 = sum(cumul &lt; 0.9 * float(suma_de_frecuencias))
      
      # List of statistics values i am trying to get
      
      D10 = df['Size'].iloc[D10]
      
      D50 = df['Size'].iloc[D50]
      
      D90 = df['Size'].iloc[D90]
  
      
      # Storing values in an array
  
      result = [D10, D50, D90]
      
      # Appending each &quot;result&quot; in &quot;result_array&quot;
  
      result_array = np.append(result_array, result)
  
  </code></pre>
  <p>But when I try to create a dataframe, the code result to be an error</p>
  <pre class="lang-python prettyprint-override"><code>dataset = pd.DataFrame(data=result_array[1:,1:],index=result_array[1:,65],column=result_array[0,1:])
  </code></pre>
  <p>It results in an IndexError Traceback in line 40 which is for dataset</p>
  <p>Saying:</p>
  <p>IndexError: too many indices for array</p>
  <p><a href="https://i.stack.imgur.com/xoIIX.png" rel="nofollow noreferrer">IndexError</a></p>
  <p>What i would like to get is something like this:</p>
  <pre class="lang-python prettyprint-override"><code>&quot;&quot;&quot;    
          'D10'  |  'D50'  |  'D90'
     0 |  value  |  value  |  value    &lt;--- the first computated array &quot;result&quot;
     1 |  value  |  value  |  value    &lt;--- the first computated array &quot;result&quot;
     2 |  value  |  value  |  value    &lt;--- the first computated array &quot;result&quot;
     3 |  value  |  value  |  value  
     .
     .
     .
  
  &quot;&quot;&quot;
  </code></pre>