[Numpy-discussion] numpy sort is not working

Travis Oliphant travis@continuum...
Tue Sep 11 09:07:05 CDT 2012


I am wondering of this has to do with the size of the array.

It looks like the array is sorted --- but in chunks.

--
Travis Oliphant
(on a mobile)
512-826-7480


On Sep 10, 2012, at 10:46 PM, "Jadhav, Alok" <alok.jadhav@credit-suisse.com> wrote:

>  
> Hi everyone,
>  
> I have a numpy array of dimensions
>  
> >>> allRics.shape 
> (583760, 1) 
>  
> To sort the array, I set the dtype of the array as follows:
>  
> allRics.dtype = [('idx', np.float), ('opened', np.float), ('time', np.float),('trdp1',np.float),('trdp0',np.float),('dt',np.float),('value',np.float)] 
> >>> allRics.dtype
> dtype([('idx', '<f8'), ('opened', '<f8'), ('time', '<f8'), ('trdp1', '<f8'), ('trdp0', '<f8'), ('dt', '<f8'), ('value', '<f8')])
>  
> I checked and the endianness in dtype is correct.
>  
> When I sort the array, the output array of sort is same as original array without any change. I want to sort the allRics numpy array on ‘time’. I do the following.
>  
> >>> x=np.sort(allRics,order='time')
> >>> x[17330:17350]['time']
> array([[ 61184.4  ],
>        [ 61188.51 ],
>        [ 61188.979],
>        [ 61188.979],
>        [ 61189.989],
>        [ 61191.66 ],
>        [ 61194.35 ],
>        [ 61194.35 ],
>        [ 61198.79 ],
>        [ 61198.145],
>        [ 36126.217],
>        [ 36126.217],
>        [ 36126.218],
>        [ 36126.218],
>        [ 36126.219],
>        [ 36126.271],
>        [ 36126.271],
>        [ 36126.271],
>        [ 36126.293],
>        [ 36126.293]])
>  
> Time column doesn’t change its order. Could someone please advise what is missing here? Is this related to the bug
> http://www.mail-archive.com/numpy-discussion@scipy.org/msg23060.html  (from 2010).
>  
> Regards,
> Alok
>  
>  
>  
>  
>  
> Alok Jadhav
> CREDIT SUISSE AG
> GAT IT Hong Kong, KVAG 67
> International Commerce Centre | Hong Kong | Hong Kong
> Phone +852 2101 6274 | Mobile +852 9169 7172
> alok.jadhav@credit-suisse.com | www.credit-suisse.com
>  
> 
> ==============================================================================
> Please access the attached hyperlink for an important electronic communications disclaimer:
> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
> ==============================================================================
> 
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120911/808f30af/attachment-0001.html 


More information about the NumPy-Discussion mailing list