h2o:遍历行 [英] h2o: iterate through rows
问题描述
我知道h2o的内部数据模型是面向列的(即H2OFrame是H2OVec的集合).但是,我要使用的库需要遍历H2OFrame的行.
I know h2o's internal data model is column oriented (namely an H2OFrame is a collection of H2OVec). However, the library I'd like to use requires to iterate through the rows of an H2OFrame.
是否有一种在行上获得迭代器的干净方法,还是我需要像这样建立索引
Is there a clean way to get an iterator on the rows or do I need to resort to indexing like
iris = h2o.import_file(path=".../iris_wheader.csv")
for i in xrange(iris.nrow):
foo( iris[i,:].as_data_frame(use_pandas=False)[1] )
我知道它会很慢,如果可能的话,我会使用h2o.h2o.export_file
.
I know it's going to be slow, I'm using h2o.h2o.export_file
when possible.
推荐答案
您可以逐行应用.
iris.apply(foo,1)
You can do a row-wise apply.
iris.apply(foo,1)
foo
是h2o可以理解的lambda(在那里可以有一些限制,但是所有基本的数学运算都应该可以正常工作).
Where foo
is some lambda that h2o understands (there are some limits on what can go in there, but all basic math ops should work fine).
悬崖
这篇关于h2o:遍历行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!