当前位置: 首页>>代码示例>>Python>>正文


Python H2OFrame.py_tmp_key方法代码示例

本文整理汇总了Python中frame.H2OFrame.py_tmp_key方法的典型用法代码示例。如果您正苦于以下问题:Python H2OFrame.py_tmp_key方法的具体用法?Python H2OFrame.py_tmp_key怎么用?Python H2OFrame.py_tmp_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在frame.H2OFrame的用法示例。


在下文中一共展示了H2OFrame.py_tmp_key方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: upload_file

# 需要导入模块: from frame import H2OFrame [as 别名]
# 或者: from frame.H2OFrame import py_tmp_key [as 别名]
def upload_file(path, destination_frame=""):
  """
  Upload a dataset at the path given from the local machine to the H2O cluster.

  :param path: A path specifying the location of the data to upload.
  :param destination_frame: The name of the H2O Frame in the H2O Cluster.
  :return: A new H2OFrame
  """
  fui = {"file": os.path.abspath(path)}
  destination_frame = H2OFrame.py_tmp_key() if destination_frame == "" else destination_frame
  H2OConnection.post_json(url_suffix="PostFile", file_upload_info=fui,destination_frame=destination_frame)
  return H2OFrame(text_key=destination_frame)
开发者ID:yuecong,项目名称:h2o-3,代码行数:14,代码来源:h2o.py

示例2: ifelse

# 需要导入模块: from frame import H2OFrame [as 别名]
# 或者: from frame.H2OFrame import py_tmp_key [as 别名]
def ifelse(test,yes,no):
  """
  Semantically equivalent to R's ifelse.
  Based on the booleans in the test vector, the output has the values of the yes and no
  vectors interleaved (or merged together).

  :param test: A "test" H2OFrame
  :param yes:  A "yes" H2OFrame
  :param no:   A "no"  H2OFrame
  :return: An H2OFrame
  """
  test_a=None
  yes_a =None
  no_a  =None

  test_tmp = None
  yes_tmp  = None
  no_tmp   = None

  if isinstance(test, bool): test_a = "%TRUE" if test else "%FALSE"
  else:
    if isinstance(test,H2OVec): test_tmp = test._expr.eager()
    else:                       test_tmp = test.key()
    test_a = "'"+test_tmp+"'"
  if isinstance(yes, (int,float)): yes_a = "#{}".format(str(yes))
  elif yes is None:                yes_a = "#NaN"
  else:
    if isinstance(yes,H2OVec): yes_tmp = yes._expr.eager()
    else:                      yes_tmp = yes.key()
    yes_a = "'"+yes_tmp+"'"
  if isinstance(no, (int,float)): no_a = "#{}".format(str(no))
  elif no is None:                no_a = "#NaN"
  else:
    if isinstance(no,H2OVec): no_tmp = no._expr.eager()
    else:                     no_tmp = no.key()
    no_a = "'"+no_tmp+"'"

  tmp_key = H2OFrame.py_tmp_key()
  expr = "(= !{} (ifelse {} {} {}))".format(tmp_key,test_a,yes_a,no_a)
  rapids(expr)
  j = frame(tmp_key) # Fetch the frame as JSON
  fr = j['frames'][0]    # Just the first (only) frame
  rows = fr['rows']      # Row count
  veckeys = fr['vec_ids']# List of h2o vec keys
  cols = fr['columns']   # List of columns
  colnames = [col['label'] for col in cols]
  vecs=H2OVec.new_vecs(zip(colnames, veckeys), rows) # Peel the Vecs out of the returned Frame
  removeFrameShallow(tmp_key)
  if yes_tmp is not  None: removeFrameShallow(str(yes_tmp))
  if no_tmp is not   None: removeFrameShallow(str(no_tmp))
  if test_tmp is not None: removeFrameShallow(str(test_tmp))
  return H2OFrame(vecs=vecs)
开发者ID:jethrotan,项目名称:h2o-3,代码行数:54,代码来源:h2o.py

示例3: parse_raw

# 需要导入模块: from frame import H2OFrame [as 别名]
# 或者: from frame.H2OFrame import py_tmp_key [as 别名]
def parse_raw(setup, id=None, first_line_is_header=(-1,0,1)):
  """
  Used in conjunction with import_file and parse_setup in order to make alterations before parsing.
  :param setup: Result of h2o.parse_setup
  :param id: An optional id for the frame.
  :param first_line_is_header: -1,0,1 if the first line is to be used as the header
  :return: An H2OFrame object
  """
  if id is None: id = H2OFrame.py_tmp_key()
  parsed = parse(setup, id, first_line_is_header)
  veckeys = parsed['vec_ids']
  rows = parsed['rows']
  cols = parsed['column_names'] if parsed["column_names"] else ["C" + str(x) for x in range(1,len(veckeys)+1)]
  vecs = H2OVec.new_vecs(zip(cols, veckeys), rows)
  return H2OFrame(vecs=vecs)
开发者ID:yuecong,项目名称:h2o-3,代码行数:17,代码来源:h2o.py

示例4: rep_len

# 需要导入模块: from frame import H2OFrame [as 别名]
# 或者: from frame.H2OFrame import py_tmp_key [as 别名]
def rep_len(data, length_out):
  if isinstance(data, (str, int)):
    tmp_key = H2OFrame.py_tmp_key()
    scaler = '#{}'.format(data) if isinstance(data, int) else '\"{}\"'.format(data)
    expr = "(= !{} (rep_len {} {}))".format(tmp_key,scaler,'#{}'.format(length_out))
    rapids(expr)
    j = frame(tmp_key)
    fr = j['frames'][0]
    rows = fr['rows']
    veckeys = fr['vec_ids']
    cols = fr['columns']
    colnames = [col['label'] for col in cols]
    vecs=H2OVec.new_vecs(zip(colnames, veckeys), rows)
    removeFrameShallow(tmp_key)
    return H2OFrame(vecs=vecs)
  return data.rep_len(length_out=length_out)
开发者ID:jethrotan,项目名称:h2o-3,代码行数:18,代码来源:h2o.py

示例5: ls

# 需要导入模块: from frame import H2OFrame [as 别名]
# 或者: from frame.H2OFrame import py_tmp_key [as 别名]
def ls():
  """
  List Keys on an H2O Cluster
  :return: Returns a list of keys in the current H2O instance
  """
  tmp_key = H2OFrame.py_tmp_key()
  expr = "(= !{} (ls ))".format(tmp_key)
  rapids(expr)
  j = frame(tmp_key)
  fr = j['frames'][0]
  rows = fr['rows']
  veckeys = fr['vec_ids']
  cols = fr['columns']
  colnames = [col['label'] for col in cols]
  vecs=H2OVec.new_vecs(zip(colnames, veckeys), rows)
  fr = H2OFrame(vecs=vecs)
  print "First 10 Keys: "
  fr.show()
  return as_list(fr, use_pandas=False)
开发者ID:jethrotan,项目名称:h2o-3,代码行数:21,代码来源:h2o.py

示例6: cbind

# 需要导入模块: from frame import H2OFrame [as 别名]
# 或者: from frame.H2OFrame import py_tmp_key [as 别名]
def cbind(left,right):
  """
  :param left: H2OFrame or H2OVec
  :param right: H2OFrame or H2OVec
  :return: new H2OFrame with left|right cbinded
  """
  # Check left and right data types
  vecs = []
  if isinstance(left,H2OFrame) and isinstance(right,H2OFrame):
    vecs = left._vecs + right._vecs
  elif isinstance(left,H2OFrame) and isinstance(right,H2OVec):
    [vecs.append(vec) for vec in left._vecs]
    vecs.append(right)
  elif isinstance(left,H2OVec) and isinstance(right,H2OVec):
    vecs = [left, right]
  elif isinstance(left,H2OVec) and isinstance(right,H2OFrame):
    vecs.append(left)
    [vecs.append(vec) for vec in right._vecs]
  else:
    raise ValueError("left and right data must be H2OVec or H2OFrame")
  names = [vec.name() for vec in vecs]

  fr = H2OFrame.py_tmp_key()
  cbind = "(= !" + fr + " (cbind %FALSE %"
  cbind += " %".join([vec._expr.eager() for vec in vecs]) + "))"
  rapids(cbind)

  j = frame(fr)
  fr = j['frames'][0]
  rows = fr['rows']
  vec_ids = fr['vec_ids']
  cols = fr['columns']
  colnames = [col['label'] for col in cols]
  result = H2OFrame(vecs=H2OVec.new_vecs(zip(colnames, vec_ids), rows))
  result.setNames(names)
  return result
开发者ID:yuecong,项目名称:h2o-3,代码行数:38,代码来源:h2o.py


注:本文中的frame.H2OFrame.py_tmp_key方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。