<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to merge all the columns into one column as JSON? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-merge-all-the-columns-into-one-column-as-json/m-p/22122#M15115</link>
    <description>&lt;P&gt;I have a task to transform a dataframe. &lt;/P&gt;&lt;P&gt;The task is to collect all the columns in a row and embed it into a JSON string as a column.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Source DF:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/1912iEC3E889EFB0185BA/image-size/large?v=v2&amp;amp;px=999" role="button" title="image" alt="image" /&gt;&lt;/span&gt;Target DF:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/1909i6A1A42493D4C98D6/image-size/large?v=v2&amp;amp;px=999" role="button" title="image" alt="image" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Apr 2022 12:15:17 GMT</pubDate>
    <dc:creator>AmanSehgal</dc:creator>
    <dc:date>2022-04-26T12:15:17Z</dc:date>
    <item>
      <title>How to merge all the columns into one column as JSON?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-merge-all-the-columns-into-one-column-as-json/m-p/22122#M15115</link>
      <description>&lt;P&gt;I have a task to transform a dataframe. &lt;/P&gt;&lt;P&gt;The task is to collect all the columns in a row and embed it into a JSON string as a column.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Source DF:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/1912iEC3E889EFB0185BA/image-size/large?v=v2&amp;amp;px=999" role="button" title="image" alt="image" /&gt;&lt;/span&gt;Target DF:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/1909i6A1A42493D4C98D6/image-size/large?v=v2&amp;amp;px=999" role="button" title="image" alt="image" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2022 12:15:17 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-merge-all-the-columns-into-one-column-as-json/m-p/22122#M15115</guid>
      <dc:creator>AmanSehgal</dc:creator>
      <dc:date>2022-04-26T12:15:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge all the columns into one column as JSON?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-merge-all-the-columns-into-one-column-as-json/m-p/22123#M15116</link>
      <description>&lt;P&gt;I was able to do this by converting df to rdd and then by applying map function to it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;rdd_1 = df.rdd.map(lambda row: 
                             (row['ID'],
                             row.asDict()
                             )
              )
&amp;nbsp;
rdd_2_df = rdd_1.toDF(['ID', 'Data'])&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 07:14:26 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-merge-all-the-columns-into-one-column-as-json/m-p/22123#M15116</guid>
      <dc:creator>AmanSehgal</dc:creator>
      <dc:date>2022-04-27T07:14:26Z</dc:date>
    </item>
  </channel>
</rss>

