本文整理汇总了Python中expr.Expr.is_local方法的典型用法代码示例。如果您正苦于以下问题:Python Expr.is_local方法的具体用法?Python Expr.is_local怎么用?Python Expr.is_local使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类expr.Expr
的用法示例。
在下文中一共展示了Expr.is_local方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __getitem__
# 需要导入模块: from expr import Expr [as 别名]
# 或者: from expr.Expr import is_local [as 别名]
def __getitem__(self, i):
"""
Column selection via integer, string(name)
Column selection via slice returns a subset of the H2OFrame
:param i: An int, str, slice, H2OVec, or list/tuple
:return: An H2OVec, an H2OFrame, or scalar depending on the input slice.
"""
if self._vecs is None or self._vecs == []:
raise ValueError("Frame Removed")
if isinstance(i, int): return self._vecs[i]
if isinstance(i, str): return self._find(i)
# Slice; return a Frame not a Vec
if isinstance(i, slice): return H2OFrame(vecs=self._vecs[i])
# Row selection from a boolean Vec
if isinstance(i, H2OVec):
self._len_check(i)
return H2OFrame(vecs=[x.row_select(i) for x in self._vecs])
# have a list/tuple of numbers or strings
if isinstance(i, list) or (isinstance(i, tuple) and len(i) != 2):
vecs = []
for it in i:
if isinstance(it, int): vecs.append(self._vecs[it])
elif isinstance(it, str): vecs.append(self._find(it))
else: raise NotImplementedError
return H2OFrame(vecs=vecs)
# multi-dimensional slicing via 2-tuple
if isinstance(i, tuple):
veckeys = [str(v._expr._data) for v in self._vecs]
left = Expr(veckeys)
rite = Expr((i[0], i[1]))
res = Expr("[", left, rite, length=2)
if not isinstance(i[0], int) or not isinstance(i[1], int): return res # possible big data
# small data (single value)
res.eager()
if res.is_local(): return res._data
j = h2o.frame(res._data) # data is remote
return map(list, zip(*[c['data'] for c in j['frames'][0]['columns'][:]]))[0][0]
raise NotImplementedError("Slicing by unknown type: "+str(type(i)))