RE: Rename Several Aggregated Columns

2016-03-22 Thread Andres.Fernandez
: 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(

Rename Several Aggregated Columns

2016-03-19 Thread Andres.Fernandez
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

Re: Rename Several Aggregated Columns

2016-03-19 Thread Sunitha Kambhampati
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,