You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by Cesar Flores <ce...@gmail.com> on 2015/05/19 23:11:30 UTC

Naming an DF aggregated column

I would like to ask if there is a way of specifying the column name of a
data frame aggregation. For example If I do:

customerDF.groupBy("state").agg(max($"discount"))

the name of my aggregated column will be: MAX('discount)

Is there a way of changing the name of that column to something else on the
fly, and not after performing the aggregation?


thanks
-- 
Cesar Flores

Re: Naming an DF aggregated column

Posted by Michael Armbrust <mi...@databricks.com>.
customerDF.groupBy("state").agg(max($"discount").alias("newName"))

(or .as(...), both functions can take a String or a Symbol)

On Tue, May 19, 2015 at 2:11 PM, Cesar Flores <ce...@gmail.com> wrote:

>
> I would like to ask if there is a way of specifying the column name of a
> data frame aggregation. For example If I do:
>
> customerDF.groupBy("state").agg(max($"discount"))
>
> the name of my aggregated column will be: MAX('discount)
>
> Is there a way of changing the name of that column to something else on
> the fly, and not after performing the aggregation?
>
>
> thanks
> --
> Cesar Flores
>