title: PySpark: Take average of a column after using filter function
body: <p>I am using the following code to get the average age of people whose salary is greater than some threshold.</p>
  
  <pre><code>dataframe.filter(df['salary'] &gt; 100000).agg({"avg": "age"})
  </code></pre>
  
  <p>the column age is numeric (float) but still I am getting this error.</p>
  
  <pre><code>py4j.protocol.Py4JJavaError: An error occurred while calling o86.agg. 
  : scala.MatchError: age (of class java.lang.String)
  </code></pre>
  
  <p>Do you know any other way to obtain the avg etc. without using <code>groupBy</code> function and SQL queries.</p>