I am using Python in a Pyspark framework.
I am trying to apply different aggregations on different columns using groupby
I have a df with columns col1
, col2
, col3
, col4
I want to do something like:
df.groupby("col1").sum("col2", "col3").avg("col4")
But I am getting an error:
'DataFrame' object has no attribute 'avg' Traceback (most recent call last): File "/usr/lib/spark/python/lib/pyspark.zip/pyspark/sql/dataframe.py", line 1301, in getattr "'%s' object has no attribute '%s'" % (self.class.name, name)) AttributeError: 'DataFrame' object has no attribute 'avg'