title: Pyspark - Json Column - Concat Key and Value as a String
body: <p>I have a dataframe with 2 string columns, and another one with an array strucuture:</p>
  <pre><code>-- music: string (nullable = true)
  |-- artist: string (nullable = true)
  |-- details: array (nullable = false)
  |    |-- element: struct (containsNull = true)
  |    |    |-- Genre: string (nullable = true)
  |    |    |-- Origin: string (nullable = true)
  </code></pre>
  <p>Just to help you, this is a sample data:</p>
  <pre><code>music | artist | details
  Music_1 | Artist_1 | [{&quot;Genre&quot;: &quot;Rock&quot;, &quot;Origin&quot;: &quot;USA&quot;}]
  Music_2 | Artist_3 | [{&quot;Genre&quot;: &quot;&quot;, &quot;Origin&quot;: &quot;USA&quot;}]
  Music_3 | Artist_1 | [{&quot;Genre&quot;: &quot;Rock&quot;, &quot;Origin&quot;: &quot;UK&quot;}]
  </code></pre>
  <p>I am trying a simple operation, I guess, just concat the Key and Value by '-'. Basically, what I am trying to do is to get the following strucuture:</p>
  <pre><code>music | artist | details
  Music_1 | Artist_1 | Genre - Rock, Origin - USA
  Music_2 | Artist_3 | Genre -     , Origin - USA
  Music_3 | Artist_1 | Genre - Rock, Origin - UK
  </code></pre>
  <p>For that I already tried an approach that was sparate first the key and value in different columns to then I can concat the items:</p>
  <pre><code>display(df.select(col(&quot;music&quot;), col(&quot;artist&quot;), posexplode(&quot;details&quot;).alias(&quot;key&quot;,&quot;value&quot;)))
  </code></pre>
  <p>But I got the following result:</p>
  <pre><code>music | artist | key | value
  Music_1 | Artist_1 | 0 | [{&quot;Genre&quot;: &quot;Rock&quot;, &quot;Origin&quot;: &quot;USA&quot;}]
  Music_2 | Artist_3 | 0 | [{&quot;Genre&quot;: &quot;&quot;, &quot;Origin&quot;: &quot;USA&quot;}]
  Music_3 | Artist_1 | 0 | [{&quot;Genre&quot;: &quot;Rock&quot;, &quot;Origin&quot;: &quot;UK&quot;}]
  </code></pre>
  <p>Probably is not the best solution, anyone can help me?</p>
  <p>Thanks!</p>