Search code examples
pythondataframeh2o

How to create a H2O data frame in Python?


[Edited for clarity] I'd like to create a H2O data frame in Python with a given number of rows and columns. I can see that there is a nice function in R. Is there a corresponding one in Python? Just to be precise, let's say I want to create a H2O dataframe of zeros with 10 rows and 5 columns. How do I do that? Something like this doesn't work:

h2o.createFrame(rows = 10, cols = 5, value = 0)

Solution

  • There is an h2o.H2OFrame() function that takes several types of input (list, tuple, dictionary, Pandas DataFrame, Scipy sparse matrix). More info on the H2OFrame constructor here, and general info about data manipulation in H2O here.

    Example:

    import h2o
    hf = h2o.H2OFrame([[2,3],[4,5]])