abstract fun select(vararg columns: String): DataFrame
open fun select(vararg columns: ColumnSelector): DataFrame
Create a new data frame with only the selected columns.
// data-frames can be a mix of atomic (int, double, boolean, string) and object columns
val birthdays = DataFrame.builder("name", "height", "sex", "birthday")(
"Tom", 1.89, Sex.MALE, LocalDate.of(1980, 5, 22),
"Jane", 1.73, Sex.FEMALE, LocalDate.of(1973, 2, 13)
)
// just select/deselect columns of interest with varargs
birthdays.select("name", "height")
birthdays.remove("sex")
// use helper API to match columns of interest
birthdays.select { matches("^na") }
birthdays.select { endsWith("x") }
// do positive and negative selection as needed
birthdays.remove { startsWith("birth") }
birthdays.select { except("birth") }
// or use stdlib-like filter with `selectIf`
birthdays.selectIf { it is IntCol }
birthdays.selectIf { it.name.startsWith("bar") }
open fun select(columns: Iterable<String>): DataFrame
Convenience wrapper around to work with varag krangl.DataFrame.select
open fun select(columnSelect: ColumnSelector): DataFrame
Keeps only the variables that match any of the given expressions.
E.g. use startsWith("foo")
to select for
columnSelect staring with 'foo'.
// data-frames can be a mix of atomic (int, double, boolean, string) and object columns
val birthdays = DataFrame.builder("name", "height", "sex", "birthday")(
"Tom", 1.89, Sex.MALE, LocalDate.of(1980, 5, 22),
"Jane", 1.73, Sex.FEMALE, LocalDate.of(1973, 2, 13)
)
// just select/deselect columns of interest with varargs
birthdays.select("name", "height")
birthdays.remove("sex")
// use helper API to match columns of interest
birthdays.select { matches("^na") }
birthdays.select { endsWith("x") }
// do positive and negative selection as needed
birthdays.remove { startsWith("birth") }
birthdays.select { except("birth") }
// or use stdlib-like filter with `selectIf`
birthdays.selectIf { it is IntCol }
birthdays.selectIf { it.name.startsWith("bar") }