python - 尝试切片行时挂起的问题
问题描述
我猜我猜是一个中等大小的数据帧,大约 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):
解决方案
推荐阅读
- angular-material - 如何为 Angular Material 拖放 v10 提供混合方向
- android-pay - 如何在 Google Pass 活动门票徽标中使用 base64 字符串
- ios - iOS:如何为 3 个具有相同持续时间和重复的序列设置动画?
- python - 类似于点积的自定义 keras 层
- wpf - 在 xaml 中使用前导空格为标签格式化双精度
- colors - 具有多种颜色的 ifc 对象
- visual-studio-code - 使 VSCode 修剪仅包含空格的行,但不修剪带有尾随空格的文本行
- sql - 即使使用 group by 也会返回重复的行
- apple-push-notifications - Java 1.6 支持向 Apple 的新 HTTP/2 规范发送通知负载
- python - 如何在此裁剪图像中获取 x,y,w,h 的每个值?