That's just the way it works in numpy. Slices return arrays of lower rank. If you want arrays that behave like they do in linear algebra you can use 'matrix' instead. Check out the Numpy for Matlab users page for more info on array vs. matrix. http://www.scipy.org/NumPy_for_Matlab_Users --bb On 8/30/06, Rahul Kanwar <rkanwar@geol.sc.edu> wrote:
Hello,
I am trying to extract a column from a 2D array here is what is have done:
-------------------------------------------- In [3]: a = array([[1,2,3],[1,2,3]])
In [4]: a Out[4]: array([[1, 2, 3], [1, 2, 3]])
In [5]: a[:, 1] Out[5]: array([2, 2])
In [6]: a[:, 1:2] Out[6]: array([[2], [2]]) --------------------------------------------
when i use a[:, 1] i get a 1x2 array where as when i use a[:, 1:2] i get a 2x1 array. The intuitive behavior of a[:, 1] should be a 2x1 array. Am i doing something wrong here or is there some reason for this behavior ?
regards, Rahul
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion