[Numpy-discussion] numpy sort is not working

Jadhav, Alok alok.jadhav@credit-suisse....
Tue Sep 11 10:10:03 CDT 2012


The sorted array you see is the same as original array. I have replied to code to generate the below data. (done in a loop. Each loop generates sorted numpy arrayas it reads from file) and combines all arrays into a single numpy array. I need to sort the final array into a single sorted array. It could be because of array size. It maybe silently failing somewhere? I  don’t see any error, but output is not sorted. Array sorting works fine if the array is not structured.

 

Alok Jadhav

GAT IT Hong Kong

+852 2101 6274 (*852 6274)

 

From: numpy-discussion-bounces@scipy.org [mailto:numpy-discussion-bounces@scipy.org] On Behalf Of Travis Oliphant
Sent: Tuesday, September 11, 2012 10:07 PM
To: Discussion of Numerical Python
Subject: Re: [Numpy-discussion] numpy sort is not working

 

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 <http://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


=============================================================================== 
Please access the attached hyperlink for an important electronic communications disclaimer: 
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html 
=============================================================================== 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120911/39fe7f95/attachment.html 


More information about the NumPy-Discussion mailing list