我正在尝试从 graphlab SFrame 访问多行并将它们转换为 numpy 数组。
我有一个 96000 行和 4096 列的数据库 fd,需要检索存储在 numpy 数组中的行号。我想出的方法很慢。我怀疑这是因为我在每次迭代时不断增加 sframe 的大小,但我不知道是否有任何方法可以预先分配值。我需要抓取 20000 行并且当前方法没有完成。
fd=fd.add_row_number()
print(indexes)
xs=fd[fd['id'] == indexes[0]] #create the first entry
t=time.time()
for i in indexes[1:]: #Parse through and get indeces
t=time.time()
xtemp=fd[fd['id'] == i]
xs=xs.append(xtemp) #append the new row to the existing sframe
print(time.time()-t)
xs.remove_column('id') #remove the ID Column
print(time.time()-t)
x_sub=xs.to_numpy() #Convert the sframe to numpy