title: Concat multiple columns with loop Pyspark
body: <p>I have n arrays of string columns. I would like concatenate this n columns in one, using a loop.</p>
  
  <p>I have this function to concat columns:</p>
  
  <pre><code>def concat(type):
      def concat_(*args):
          return list(chain(*args))
      return udf(concat_, ArrayType(type))
  
  concat_string_arrays = concat(StringType())
  </code></pre>
  
  <p>And in the following example, I have 4 columns that I will concatenate like this:</p>
  
  <pre><code>df_aux = df.select('ID_col',concat_string_arrays(col("patron_txt_1"),col("patron_txt_2"),col('patron_txt_3'),col('patron_txt_0')).alias('patron_txt')
  </code></pre>
  
  <p>But, if I have 200 columns, how can I use dynamically this function  with a loop?</p>