Drop or keep columns or observations from the current H2O frame

Syntax

Drop columns

    _h2oframe _drop columnlist

Keep columns

    _h2oframe _keep columnlist

Keep observations that satisfy the specified condition in the specified range

    _h2oframe _keep {if exp} {in range}

columnlist is a list of column names in the H2O frame; see Specifying a list of columns for more information.

Description

_h2oframe _drop eliminates columns from the current H2O frame.

_h2oframe _keep keeps columns or observations from the current H2O frame.

Warning: _h2oframe _drop and _h2oframe _keep are not reversible. Once you have eliminated columns or observations, you cannot read them back in again. You would need to go back to the original H2O frame and read the data in again. Instead of applying _h2oframe _drop or _h2oframe _keep for a subset analysis, you can use _h2oframe _put to place a subset of variables or observations from the current dataset into another H2O frame. Alternatively, you can use _h2oframe _copy to make a copy of the original H2O frame and then work on the duplicated frame instead of on the original H2O frame.

Examples

 Setup
     . sysuse auto
     . _h2oframe _put, into(auto)
     . _h2oframe _change auto

 Describe the data
     . _h2oframe _describe

 Drop all columns with names that begin with t
     . _h2oframe _drop t*

 Describe the resulting data
     . _h2oframe _describe

 Drop mpg and price
     . _h2oframe _drop mpg price

 Describe the resulting data
     . _h2oframe _describe

 Keep the first 20 observations
     . _h2oframe _keep in 1/20

 Describe the resulting data
     . _h2oframe _describe