How to lowecase or uppercase column header in scala spark dataframe?

Viewed 29

I am seeing warning method toLowerCase , is there any a better approach to lowercase column header. Also df.toDF(df.columns map(_.toLowerCase): _*) did not work.

I tried:

df.select(df.columns.map(x=> col(x).as(x.toLowerCase)):_*).show(false) 
 
warning: Passing an explicit array value to a Scala varargs method is deprecated (since 2.13.0) and will result in a defensive copy; Use the more efficient non-copying ArraySeq.unsafeWrapArray or an explicit toIndexedSeq call```

0 Answers
Related