How H2O operates on date-time function (Example in R)

If you would like to know how H2O backend operates with date/time functions here is an example in R:

# Creating 3 different arrays of equal elements
> emp = c(“aa”, “bb”, “cc”)
> salary = c(1000,2000,1500)
> time = as.Date(c(‘2016-01-01 12:30:00’, ‘2016-02-02 10:10:22’, ‘2016-05-02 01:01:30’))
# Merging all arrays to create a data frame
> df = data.frame(emp, salary, time, stringsAsFactors = FALSE)
> df
# create an h2o frame from dataframe
> df.h2o = as.h2o(df)
> df.h2o
> print(df.h2o)
# Priting specific columns
> df.h2o[‘time’]
> df.h2o[’emp’]
> df.h2o[‘salary’]
# Using H2O Date/Time functions as below:
> h2o.year(df.h2o[‘time’])
> h2o.dayOfWeek(df.h2o[‘time’])
# Adding a new column based on H2O date/time functions
> df.h2o[‘dayofweek’] = h2o.dayOfWeek(df.h2o[‘time’])
# Verifying the results
> df
> df.h2o

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s