title: How to loop through the Dataframe which is of type of Array and append the value to a final Dataframe using Scala
body: <p>Please could you help me with the solution for the below Questions: Question 01: Is there a way i can loop only Array types as 
  looping string type within an array will throw an error. I cannot drop String Type(VIN) as i need this data on the final df. </p>
  
  <pre><code>df.printSchema
  </code></pre>
  
  <p>returns:</p>
  
  <pre><code>root
    |-- APP: array (nullable = true)
    |    |-- element: struct (containsNull = true)
    |    |    |-- E: long (nullable = true)
    |    |    |-- V: double (nullable = true)
    |-- B1X: array (nullable = true)
    |    |-- element: struct (containsNull = true)
    |    |    |-- E: long (nullable = true)
    |    |    |-- V: long (nullable = true)
    |-- B2X: array (nullable = true)
    |    |-- element: struct (containsNull = true)
    |    |    |-- E: long (nullable = true)
    |    |    |-- V: long (nullable = true)
    |-- B3X: array (nullable = true)
    |    |-- element: struct (containsNull = true)
    |    |    |-- E: long (nullable = true)
    |    |    |-- V: long (nullable = true)
    |-- VIN: string (nullable = true)
  </code></pre>
  
  <p>After running the below forloop:</p>
  
  <p>Question 02: Dataframe jsonDF2 is holding only the last E, V value as stime, can_value of the last signal B3X. Is  there a way to append all the values( i mean all the signal values{APP, B1X, B2X, B3X, VIN}) to a Dataframe jsonDF2 
  after it comes out of foreach loop.</p>
  
  <pre><code>val columns:Array[String] = df.columns
  
  for(col_name &lt;- columns){
  |       df = df.withColumn("element", explode(col(col_name)))
  |         .withColumn("stime", col("element.E"))
  |         .withColumn("can_value", col("element.V"))
  |         .withColumn("SIGNAL", lit(col_name))
  |         .drop(col("element"))
  |         .drop(col(col_name))
  |     }
  </code></pre>