I have a data frame df
df = source_df.select("data.*").distinct()
df.show(20,false)
---------------+----------------+--------------------------+
id |_name |_address |area |
--------------------------+----------------+---------------+
222222222222444|null |india |Default Value |
000000000055555|null |usa |Default Value |
+--------------+----------------+--------------------------+
I want to replace spacial character(_) from beginning of column name , and the desire output will be
---------------+----------------+--------------------------+
id |name |address |area |
--------------------------+----------------+---------------+
222222222222444|null |india |Default Value |
000000000055555|null |usa |Default Value |
+--------------+----------------+--------------------------+
i have tried with below statement but count not found desire output
df=df.columns.foldLeft(df){(newdf, colname) =>newdf.withColumnRenamed(colname, colname.replace("^_", ""))}