title: How can I prevent the TypeError: list indices must be integers, not tuple when copying a python list to a numpy array?
body: <p>I am trying to create 3 numpy arrays/lists using data from another array called mean_data as follows:</p>
  
  <pre><code>---&gt; 39 R = np.array(mean_data[:,0])
       40 P = np.array(mean_data[:,1])
       41 Z = np.array(mean_data[:,2])
  </code></pre>
  
  <p>When I try run the program I get the error:</p>
  
  <pre><code>TypeError: list indices must be integers, not tuple
  </code></pre>
  
  <p>The mean_data list looks like this sample...</p>
  
  <pre><code>[6.0, 315.0, 4.8123788544375692e-06],
  [6.5, 0.0, 2.259217450023793e-06],
  [6.5, 45.0, 9.2823565008402673e-06],
  [6.5, 90.0, 8.309270169336028e-06],
  [6.5, 135.0, 6.4709418114245381e-05],
  [6.5, 180.0, 1.7227922423558414e-05],
  [6.5, 225.0, 1.2308522579848724e-05],
  [6.5, 270.0, 2.6905672894824344e-05],
  [6.5, 315.0, 2.2727114437176048e-05]]
  </code></pre>
  
  <p>I don't know how to prevent this error, I have tried creating mean_data as a np.array and using np.append to add values to it but that doesn't solve the problem either.</p>
  
  <p>Here's the traceback (was using ipython before)</p>
  
  <pre><code>Traceback (most recent call last):
    File "polarplot.py", line 36, in &lt;module&gt;
      R = np.array(mean_data[:,0])
  TypeError: list indices must be integers, not tuple
  </code></pre>
  
  <p>And the other way I tried to create an array was:</p>
  
  <pre><code>mean_data = np.array([])
  
  for ur, ua in it.product(uradius, uangle):
      samepoints = (data[:,0]==ur) &amp; (data[:,1]==ua)
      if samepoints.sum() &gt; 1:  # check if there is more than one match
          np.append(mean_data[ur, ua, np.mean(data[samepoints,-1])])
      elif samepoints.sum() == 1:
          np.append(mean_data, [ur, ua, data[samepoints,-1]])
  </code></pre>
  
  <p>The traceback on that is:</p>
  
  <pre><code>IndexError                                Traceback (most recent call last)
  &lt;ipython-input-3-5268bc25e75e&gt; in &lt;module&gt;()
       31     samepoints = (data[:,0]==ur) &amp; (data[:,1]==ua)
       32     if samepoints.sum() &gt; 1:  # check if there is more than one match
  ---&gt; 33         np.append(mean_data[ur, ua, np.mean(data[samepoints,-1])])
       34     elif samepoints.sum() == 1:
       35         np.append(mean_data, [ur, ua, data[samepoints,-1]])
  
  IndexError: invalid index
  </code></pre>