Argsort On A Pytables' Array
I have a problem with NumPy's argsort. It creates an int64 array of the length of the input array in-memory. Since I'm working with very large arrays, this will blow the memory. I
Solution 1:
Since you are working with Pytables, I suggest you use the Table class which has sorting built in.
%pylab
import tables
#create description of your table
class Table_Description(tables.IsDescription):
column_name = tables.Int64Col()
#create hdf5 file and table
f=tables.open_file('test.h5',mode="w")
a=f.create_table("/","my_table",description=Table_Description)
# fill table
a.append(array([randint(0,99999) for i in xrange(10000)]))
#Create a full index (on disk if you use the tmp_dir parameter
a.cols.column_name.create_index(9,kind='full',tmp_dir="/tmp/")
#write changes to disc
a.flush()
#read indices that will sort the table
ind=f.root.my_table.cols.column_name.index
ind.read_indices()
Post a Comment for "Argsort On A Pytables' Array"