One way is to rename the columns using the toDF For eg:
val df = Seq((1, 2),(1,4),(2,3) ).toDF("a","b") df.printSchema() val renamedf = df.groupBy('a).agg(sum('b)).toDF("mycola", "mycolb") renamedf.printSchema() Best regards, Sunitha > On Mar 18, 2016, at 9:10 AM, andres.fernan...@wellsfargo.com wrote: > > Good morning. I have a dataframe and would like to group by on two fields, > and perform a sum aggregation on more than 500 fields, though I would like to > keep the same name for the 500 hundred fields (instead of sum(Field)). I do > have the field names in an array. Could anybody help with this question > please? >