首页 > 解决方案 > 尝试切片行时挂起的问题

问题描述

我猜我猜是一个中等大小的数据帧,大约 500k 行和 200 列,内存为 8GB。

我的问题是,当我要对数据进行切片时,即使是非常小的数据集,当它被修剪到 6k 行和 200 列时,它只会挂起并挂起 10/15 分钟以上。然后,如果我点击 STOP 按钮进行 python 交互并重试该过程会在 2-3 秒内发生。

我不知道为什么我可以在这 2-3 秒内正常进行行切片。这使得程序无法运行,因为事情只是挂起和挂起,并且必须在它工作之前手动停止。

我正在遵循 h2o 网页上列出的方法:

import h2o
h2o.init()

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

# Slice 1 row by index
c1 = df[15,:]
c1.describe

# Slice a range of rows
c1_1 = df[range(25,50,1),:]
c1_1.describe

# Slice using a boolean mask. The output dataset will include rows with a sepal length
# less than 4.6.
mask = df["sepal_len"] < 4.6
cols = df[mask,:]
cols.describe

# Filter out rows that contain missing values in a column. Note the use of '~' to
# perform a logical not.
mask = df["sepal_len"].isna()
cols = df[~mask,:]
cols.describe

来自控制台的错误消息如下。我重复了多次相同的错误消息。:

/opt/anaconda3/lib/python3.7/site-packages/h2o/expr.py in (.0)
    149             return self._cache._id  # Data already computed under ID, but not cached
    150         assert isinstance(self._children,tuple)
--> 151         exec_str = "({} {})".format(self._op, " ".join([ExprNode._arg_to_expr(ast) for ast in self._children]))
    152         gc_ref_cnt = len(gc.get_referrers(self))
    153         if top or gc_ref_cnt >= ExprNode.MAGIC_REF_COUNT:

~/opt/anaconda3/lib/python3.7/site-packages/h2o/expr.py in _arg_to_expr(arg)
    161             return "[]"  # empty list
    162         if isinstance(arg, ExprNode):
--> 163             return arg._get_ast_str(False)
    164         if isinstance(arg, ASTId):

标签: pythonh2o

解决方案


推荐阅读