val df = ss.sparkContext.parallelize( Seq ( ("c1", "JAN-2017", 49 ), ("c1", "MAR-2017", 83), )).toDF("city", "month", "sales") df.show() val mask = udf( (s : String) => { "*** Masked ***" }) df.withColumn("city", mask($"city")).show`