title: How to fix IndexError while creating a CSV table in python?
body: <p>As shown by below, I was trying to create a CSV table in python, which can help to calculate out the results of two equations based on the given standard error and different nodes numbers. When I ran the code, there was an error existed, but I did not get which part I have done in the wrong way. Can anyone just help on this, thanks! </p>
  
  <pre><code>from __future__ import division
  from IPython.display import HTML
  from IPython.display import display
  from scipy.special import erf
  from scipy.special import erfc
  from math import factorial as factorial
  from random import seed
  from random import randint
  import numpy as np
  import pandas as pd
  import matplotlib.pyplot as plt
  </code></pre>
  
  <p>third and fourth array was used to store the values of the generated results with the same length as the nodes array</p>
  
  <pre><code>nodes = [2, 3, 5, 10, 20, 30]
  a = 0.987654321
  third = np.zeros(shape=(len(nodes)))
  fourth = np.zeros(shape=(len(nodes)))
  </code></pre>
  
  <p>The following are the code and existed error</p>
  
  <pre><code># 1st N, 2nd α=0.987654321, 3rd and 4th are two equations
  def two_i(nodes):
      for i in nodes:
          for j in third:
              third[j] = a*(1-(1/(np.sqrt(2*i-2))))
          for k in fourth:
              fourth[k] = a*(1+(1/(np.sqrt(2*i-2))))
      dataframe = pd.DataFrame({'N':nodes,'α':a, 'Third':third, 'Fourth':fourth})
      dataframe.to_csv("question2.csv",index = False, sep = ',')
      print(dataframe)
  two_i(nodes)
  
  ---------------------------------------------------------------------------
  IndexError                                Traceback (most recent call last)
  &lt;ipython-input-30-220877b1f369&gt; in &lt;module&gt;()
        9     dataframe.to_csv("question2.csv",index = False, sep = ',')
       10     print(dataframe)
  ---&gt; 11 two_i(nodes)
  
  &lt;ipython-input-30-220877b1f369&gt; in two_i(nodes)
        3     for i in nodes:
        4         for j in third:
  ----&gt; 5             third[j] = a*(1-(1/(np.sqrt(2*i-2))))
        6         for k in fourth:
        7             fourth[k] = a*(1+(1/(np.sqrt(2*i-2))))
  
  IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
  </code></pre>