title: in numpy array, I want to copy one column to another matrix and remove the column from original matrix
body: <pre><code>mat=[[0,1,5],[1,3,6],[-1,4,4],[1,2,2],[7,3,7],[2,5,3]]  
  </code></pre>
  
  <p>mat matrix shape could be a 10000*5. here just an example</p>
  
  <p>Here I define a function. It tries to find mat[:,0] &lt; be or mat[:,0] > ba or mat[:,1] &lt; bb. If one column match the condition, the element[i,0] &lt; be  the element[i,0]=be, then copy the column to another matrix "swape". Also delete this column from matrix "mat". Same as mat[:,0] > ba or mat[:,1] &lt; bb. For mat[:,1] &lt; bb, the colume will copy to "swapt",mat[:,0] > ba don't copy, just delete.</p>
  
  <p>example be=0, ba=6,bb=3</p>
  
  <p>The return list should be :</p>
  
  <pre><code>mat=[[1,3,6],[2,5,3]]
  swape=[[-1,4,4]]
  swapt=[[1,2,2],[0,1,5]]
  </code></pre>
  
  <p>The function will return mat, swape, and swapt</p>
  
  <pre><code>def swapco(be,ba,bb,mat):
          swape=np.array()
          swapt=np.array()
          leng=np.shape(mat)[0]
          for i in range(leng):
              if mat[i,2]&lt;bb: 
                  mat[i,2]=bb   
                  np.append(swapt,i,1)
                  np.delete(mat, i, 0)
              else:
                  if mat[i,0]&gt;=ba:    
                      mat[i,0]=ba 
                      np.append(swape,i,1)
                      np.delete(mat, i, 0)
                  elif mat[i,0]&lt;=be:
                      mat[i,0]=be 
                      np.append(swape,i,1)
                      np.delete(mat, i, 0)
              i+=1
  
          return swape, swapt
  </code></pre>
  
  <p>In my code, I found the matrix mat length always reduce once some columns matched the condition. It will append and delete wrong column. Also the append is append a address or a deepcopy?</p>
  
  <p>If using</p>
  
  <pre><code>for col in mat:
  </code></pre>
  
  <p>Then how to delete itself in mat?
  Or any efficiency way to write this code?</p>
  
  <p>Question updated...</p>