PySpark - rename more than one column using withColumnRenamed
<p>I want to change names of two columns using spark withColumnRenamed function. Of course, I can write:</p>



<pre class="lang-py prettyprint-override"><code>data = sqlContext.createDataFrame([(1,2), (3,4)], ['x1', 'x2'])
data = (data
       .withColumnRenamed('x1','x3')
       .withColumnRenamed('x2', 'x4'))
</code></pre>

<p>but I want to do this in one step (having list/tuple of new names). Unfortunately, neither this:</p>

<pre class="lang-py prettyprint-override"><code>data = data.withColumnRenamed(['x1', 'x2'], ['x3', 'x4'])
</code></pre>

<p>nor this:</p>

<pre class="lang-py prettyprint-override"><code>data = data.withColumnRenamed(('x1', 'x2'), ('x3', 'x4'))
</code></pre>

<p>is working. Is it possible to do this that way?</p>