You'll need to use the longer form for aggregation:

tb2.groupBy("city", "state").agg(avg("price").as("newName")).show

depending on the language you'll need to import:
scala: import org.apache.spark.sql.functions._
python: from pyspark.sql.functions import *

On Mon, Mar 30, 2015 at 5:49 PM, Neal Yin <neal....@workday.com> wrote:

>  I ran a line like following:
> tb2.groupBy("city", "state").avg("price").show
>
>  I got result:
>  city                 state           AVG(price)
> Charlestown          New South Wales 1200.0
> Newton           ... MA              1200.0
> Coral Gables     ... FL              1200.0
> Castricum            Noord-Holland   1200.0
> Ornex                Rhone-Alpes     1200.0
>
>  How do I change the column name “AVG(price)” to something more readable?
>
>  Thanks,
>
>  -Neal
>

Reply via email to