Slicing Columns¶
H2O lazily slices out columns of data and will only materialize a shared copy upon some type of triggering IO. This example shows how to slice columns from a frame of data.
- r
- python
> library(h2o)
> h2o.init(nthreads=-1)
> path <- "data/iris/iris_wheader.csv"
> df <- h2o.importFile(path)
# slice 1 column by index
> c1 <- df[,1]
# slice 1 column by name
> c1_1 <- df[, "sepal_len"]
# slice cols by vector of indexes
> cols <- df[, 1:4]
# slice cols by vector of names
> cols_1 <- df[, c("sepal_len", "sepal_wid", "petal_len", "petal_wid")]