SelectSelectingOptions

Selecting Columns

Selecting columns for various DataFrame operations can be done in the following ways:

1. Columns Selection DSL

Select or express columns using the Columns Selection DSL.

This DSL is initiated by a Columns Selector lambda, which operates in the context of the Columns Selection DSL and expects you to return a SingleColumn or ColumnSet (so, a ColumnsResolver). This is an entity formed by calling any (combination) of the functions in the DSL that is or can be resolved into one or more columns.

The Columns Selection DSL allows using Extension Properties for specifying columns type- and name-safe.

Check out: Columns Selection DSL Grammar

    

See Column Selectors on the documentation website.

For example:

df.select{ length andage }

df.select{ cols(1..5) }

df.select{ colsOf<Double>() }

There's also a 'single column' variant used sometimes: Column Selection DSL.

2. Column names

Select single or multiple columns using their names as Strings. (String API).

For example:

df.select("length", "age")