我对NumPy的辩论有意见。它创建一个内存中输入数组长度的int64数组.因为我使用的是非常大的数组,这会破坏内存。
我用一个小的PyTables‘carray测试了NumPy的argsort,并给出了正确的输出。现在,我想要的是排序算法直接处理PyTables的数组。是否有一种方法可以通过标准NumPy调用或对NumPy内部进行简单的黑客攻击来做到这一点?
我也对非NumPy的选择开放-我只想把工作做完!
发布于 2015-08-31 15:36:32
由于您正在使用Pytable,我建议您使用内置了排序的Table类。
%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()
https://stackoverflow.com/questions/32312446
复制相似问题