title: Swapping columns in a numpy array?
body: <pre><code>from numpy import *
  def swap_columns(my_array, col1, col2):
      temp = my_array[:,col1]
      my_array[:,col1] = my_array[:,col2]
      my_array[:,col2] = temp
  </code></pre>
  
  <p>Then</p>
  
  <pre><code>swap_columns(data, 0, 1)
  </code></pre>
  
  <p>Doesn't work. However, calling the code directly</p>
  
  <pre><code>temp = my_array[:,0]
  my_array[:,0] = my_array[:,1]
  my_array[:,1] = temp
  </code></pre>
  
  <p>Does. Why is this happening and how can I fix it? The Error says "IndexError: 0-d arrays can only use a single () or a list of newaxes (and a single ...) as an index", which implies the arguments aren't ints? I already tried converting the cols to int but that didn't solve it.</p>