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