Question: Say I have some column names which ends with '\_undo', Now I need to remove this columns. Now instead of dropping one by one or storing them in a list before dropping, can i drop at one go?

```
df.drop(//drop at one go for those columns ending with _undo)

```

Answer: 
```
val customDF = df.select(df.columns.filter(colName => checkname(colName)) .map(colName => new Column(colName)): _*)

```

where checkname is simple user function which returns colname if matches and null if not. Use your pattern to check inside that function.

```
def checkname () : [return type] = {
   return [expr]
}

```
What about this?

```
df.drop(df.columns.filter(c => "regexp".r.pattern.matcher(c).matches): _*)

```

or

```
df.drop(df.columns.filter(_.endsWith("_undo")): _*)

```