title: How to retrieve all columns using pyspark collect_list functions
body: <p>I have a pyspark 2.0.1. I'm trying to groupby my data frame &amp; retrieve the value for all the fields from my data frame. I found that </p>
  
  <pre><code>z=data1.groupby('country').agg(F.collect_list('names')) 
  </code></pre>
  
  <p>will give me values for country &amp; names attribute &amp; for names attribute it will give column header as <code>collect_list(names)</code>. But for my job I have dataframe with around 15 columns &amp; I will run a loop &amp; will change the groupby field each time inside loop &amp; need the output for all of the remaining fields.Can you please suggest me how to do it using collect_list() or any other pyspark functions?</p>
  
  <p>I tried this code too </p>
  
  <pre><code>from pyspark.sql import functions as F 
  fieldnames=data1.schema.names 
  names1= list() 
  for item in names: 
     if item != 'names': 
       names1.append(item) 
   z=data1.groupby('names').agg(F.collect_list(names1)) 
   z.show() 
  </code></pre>
  
  <p>but got error message </p>
  
  <pre><code>Py4JError: An error occurred while calling z:org.apache.spark.sql.functions.collect_list. Trace: py4j.Py4JException: Method collect_list([class java.util.ArrayList]) does not exist 
  </code></pre>