title: Pyspark - Loop and for in Range - get the last value only
body: <p>I want to merge two columns of a dataframe two by two so I used the &quot;for in range&quot; function. However, I just, when displaying, the last result.</p>
  <p>How can I get, in a dataframe, all the results?</p>
  <p>Here is my code:</p>
  <pre><code>from pyspark.sql.functions import concat_ws, col
  
  df = spark.read.load('abfss://......')
  
  for item in range(1,21,2): 
     df2=df.select(concat_ws(&quot;/&quot;,df[item:item],df[item+1:item+1]).alias(df.columns[item:item]))
     
  display(df2)
  </code></pre>
  <p>Thanks for your help</p>