Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to interpret H2O's time data type?

Tags:

r

h2o

I have a data frame in R that I am passing to H2O using the as.h2o().

dataset.h2o <- as.h2o(dataset,destination_frame = "dataset.h2o")

Doing an str() on the data frame, we can see that the week_of_date class is of datatype Date

$ primary_account_id : int 31 31 31 31 31 31 31 31 31 31 ...
$ week_of_date : Date, format: "2015-08-31" "2015-09-07" "2015-09-14" "2015-09-21" ...

However, when viewed in H2O Flow, it seems to be converted to a datatype called time - which is of the format

week_of_date time 0 0 0 0 1440943200000.0 1447592400000.0 1444480409625.8884 2013362534.5706

When I bring back the data to R using as.data.frame

returned.dataset <- as.data.frame(dataset.h2o)

it is stored in a format that I am unable to understand and therefore parse back

$ primary_account_id: int 31 31 698 1060 1060 1060 1060 1060 1060 1133 ...
$ week_of_date :Class 'POSIXct' num [1:194] 1442757600000 1446382800000 1446382800000 1442152800000 1442757600000 ...

Could you please point me in the direction of how I can achieve better interoperability with dates between R and H2O?

Thanks!

like image 823
elvikingo Avatar asked Jan 28 '26 13:01

elvikingo


1 Answers

It is a bug in h2o. H2o returns date time in milliseconds while R expects seconds. See jira issue 3434.

What you can do in the meantime is recode the date column: as.Date(structure(returned.dataset$week_of_date/1000, class = c("POSIXct", "POSIXt")))

like image 85
phiver Avatar answered Jan 30 '26 06:01

phiver