python中的子集h2o框架 [英] subset h2o frame in python

查看:86
本文介绍了python中的子集h2o框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在python中子集h2o框架. 如果x是df& Origin是一个变量,那么在大熊猫中,我们通常可以通过以下方式进行子集

how can I subset a h2o frame in python. if x is a df & Origin is a variable then in pandas we generally can do subsetting by

x[x.Origin == 'AAF']

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

but with h2o frame it gives the following error: "H2OResponseError: Server error java.lang.IllegalArgumentException: Error: Name lookup of 'x.hex' failed"

推荐答案

有很多不同的方法可以按行对H2OFrame进行切片.在

There are a number of different ways to slice an H2OFrame, row-wise. The methods are outlined in the H2O User Guide section on Slicing Rows.

以下是一个Python示例,该示例基于使用Iris数据集将列设置为特定值来对H2OFrame进行子集设置:

Here is an Python example of subsetting an H2OFrame based on a column being set to a particular value using the Iris dataset:

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"]

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

The newdf = df[df["class"] == "Iris-setosa"] version is almost identical to the format you have above, except H2OFrames do not support referencing a column like this: df.class; you must use: df["class"].

这篇关于python中的子集h2o框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆