I have a spark data frame df
. Is there a way of sub selecting a few columns using a list of these columns?
scala> df.columns
res0: Array[String] = Array("a", "b", "c", "d")
I know I can do something like df.select("b", "c")
. But suppose I have a list containing a few column names val cols = List("b", "c")
, is there a way to pass this to df.select? df.select(cols)
throws an error. Something like df.select(*cols)
as in python
col.tail: _ *
do? – Sumerology