'Difference .sum("salary") and .sum(df.salary) in pyspark

I'm new to pyspark.

What is the difference between .sum("salary") and .sum(df.salary) in pyspark? Example below.

df_t=df.groupBy(df.dept).avg('salary') #return no error
df_t=df.groupBy(df.dept).avg(df.salary) #return error "Column is not iterable"


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source