python中的子集h2o框架

fna*_*ic9 3 python subset h2o

如何在python中对h2o帧进行子集化.如果x是df并且Origin是变量,那么在pandas中我们通常可以进行子集化

x[x.Origin == 'AAF']
Run Code Online (Sandbox Code Playgroud)

但是使用h2o框架时会出现以下错误:"H2OResponseError:服务器错误java.lang.IllegalArgumentException:错误:'x.hex'的名称查找失败"

Eri*_*ell 11

有许多不同的方法可以逐行切割H2OFrame." 切片行 "的"H2O用户指南"部分概述了这些方法.

以下是使用Iris数据集基于设置为特定值的列对H2OFrame进行子集化的Python示例:

import h2o
h2o.init()

# Load data
path = "http://h2o-public-test-data.s3.amazonaws.com/smalldata/iris/iris_wheader.csv"
df = h2o.import_file(path=path)

# Subset data
mask = df["class"] == "Iris-setosa"
newdf = df[mask, :]

# equivalent to both of these, which also work
# newdf = df[df["class"] == "Iris-setosa", :]
# newdf = df[df["class"] == "Iris-setosa"]
Run Code Online (Sandbox Code Playgroud)

newdf = df[df["class"] == "Iris-setosa"]版本几乎与您上面的格式相同,只是H2OFrames不支持引用这样的列:df.class; 你必须使用:df["class"].