title: how to get max(date) from given set of data grouped by some fields using pyspark?
body: <p>I have the data in the dataframe as below:</p>
  
  <pre><code>  datetime             | userId | memberId | value |    
  2016-04-06 16:36:...   | 1234   | 111      | 1
  2016-04-06 17:35:...   | 1234   | 222      | 5
  2016-04-06 17:50:...   | 1234   | 111      | 8
  2016-04-06 18:36:...   | 1234   | 222      | 9
  2016-04-05 16:36:...   | 4567   | 111      | 1
  2016-04-06 17:35:...   | 4567   | 222      | 5
  2016-04-06 18:50:...   | 4567   | 111      | 8
  2016-04-06 19:36:...   | 4567   | 222      | 9
  </code></pre>
  
  <p>I need to find the max(datetime) groupby userid,memberid. When I tried as below: </p>
  
  <pre><code>df2 = df.groupBy('userId','memberId').max('datetime')
  </code></pre>
  
  <p>I'm getting error as:  </p>
  
  <pre><code>org.apache.spark.sql.AnalysisException: "datetime" is not a numeric
  column. Aggregation function can only be applied on a numeric column.;
  </code></pre>
  
  <p>The output I desired is as follows:</p>
  
  <pre><code>userId | memberId | datetime
  1234   |  111     | 2016-04-06 17:50:...
  1234   |  222     | 2016-04-06 18:36:...
  4567   |  111     | 2016-04-06 18:50:...
  4567   |  222     | 2016-04-06 19:36:...
  </code></pre>
  
  <p>Can someone please help me how I get the max date among the given data using PySpark dataframes? </p>