title: Dataframe transpose with pyspark in Apache Spark
body: <p>I have a dataframe <code>df</code> that have following structure:</p>
  
  <pre><code>+-----+-----+-----+-------+
  |  s  |col_1|col_2|col_...|
  +-----+-----+-----+-------+
  | f1  |  0.0|  0.6|  ...  |
  | f2  |  0.6|  0.7|  ...  |
  | f3  |  0.5|  0.9|  ...  |
  |  ...|  ...|  ...|  ...  |
  </code></pre>
  
  <p>And I want to calculate the transpose of this dataframe so it will be look like </p>
  
  <pre><code>+-------+-----+-----+-------+------+
  |  s    | f1  | f2  | f3    |   ...|
  +-------+-----+-----+-------+------+
  |col_1  |  0.0|  0.6|  0.5  |   ...|
  |col_2  |  0.6|  0.7|  0.9  |   ...|
  |col_...|  ...|  ...|  ...  |   ...|
  </code></pre>
  
  <p>I tied this two solutions but it returns that dataframe has not the specified used method:</p>
  
  <p>method 1:</p>
  
  <pre><code> for x in df.columns:
      df = df.pivot(x)
  </code></pre>
  
  <p>method 2:</p>
  
  <pre><code>df = sc.parallelize([ (k,) + tuple(v[0:]) for k,v in df.items()]).toDF()
  </code></pre>
  
  <p>how can I fix this.</p>