Thank you! Yes that's the way to go taking care of selecting them in the proper 
order first. Added a select before the toDF and it does the trick.

From: Sunitha Kambhampati [mailto:skambha...@gmail.com]
Sent: Friday, March 18, 2016 5:46 PM
To: Fernandez, Andres
Cc: user@spark.apache.org
Subject: Re: Rename Several Aggregated Columns


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<mailto: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?

Reply via email to