'Pyspark groupby / agg function without changing the column names?

In cases where I have a large number of columns that I want to sum, average, etc., is there a way to NOT change the column names, without having to use .alias on each column? The default is to add the function to the column name (e.g. col1 becomes "avg(col1)" after taking the average), is there an efficient way to have it stay named "col1"?

df = df.groupby(seg).avg('col1')


Sources

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

Source: Stack Overflow

Solution Source