I'm trying to drop multiple columns from a dataframe. I've followed the example at https://stackoverflow.com/a/39818645/10836338 but it doesn't work for me. I am using spark 2.4.0
Here's what I'm doing right now. It does work, but I was wondering if there is a better way of doing this.
val colsToRemove = Seq("colA", "colB", "colC", etc)
var filterdDF = df
for(i <- 0 until colsToRemove.size){
filterdDF = filterdDF.drop(colsToRemove(i))
}
dropalso accepts alistof column name strings which can be used here. No need to loop.error: overloaded method value drop with alternatives: (col: org.apache.spark.sql.Column)org.apache.spark.sql.DataFrame <and> (colNames: String*)org.apache.spark.sql.DataFrame <and> (colName: String)org.apache.spark.sql.DataFrame