I have a dataframe containing multiple columns.
>>> df.take(1)
[Row(A=u'{dt:dt=string, content=Prod}', B=u'{dt:dt=string, content=Staging}')]
I want to remove both curly braces '{' and '}' from values of column A and B of df. I know we can use:
df.withColumn('A',regexp_replace('A','//{',''))
df.withColumn('A',regexp_replace('A','//}',''))
df.withColumn('B',regexp_replace('B','//}',''))
How do I replace characters dynamically for all columns of Spark dataframe? (Pandas version is shown below)
df = df.replace({'{':'','}':''},regex=True)