Reputation: 197
I have a Seq and need to use it to select columns in Java
I know about the function .select(String col, Seq<String> cols)
but I don't have the first column name.
Upvotes: 1
Views: 444
Reputation: 1348
If you want to select using a Seq<String>
you can split the Seq
extracting the first element separately:
Seq<String> columns = /* ... */;
Dataframe<Row> newDf = df.select(
columns.apply(0), // first element
columns.slice(1, columns.size()) // from the second to the end
);
maybe check the length of columns
first, to avoid IndexOutOfBoundsException
Upvotes: 1