<?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 Is there a way to CONCAT two dataframes on either of the axis (row/column) and transpose the dataframe in PySpark? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/is-there-a-way-to-concat-two-dataframes-on-either-of-the-axis/m-p/18550#M12326</link>
    <description>&lt;P&gt;I'm reshaping my dataframe as per requirement and I came across this situation where I'm concatenating 2 dataframes and then transposing them. I've done this previously using pandas and the syntax for pandas goes as below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;import pandas as pd
&amp;nbsp;
df1 = pd.DataFrame(some_dict)
df2 = pd.DataFrame(some_dict)
&amp;nbsp;
new_df = pd.concat( [df1, df2], axis = "column") #stacking the dfs side by side
&amp;nbsp;
trans_df = new_df.transpose() or simply new_df.T&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is there a way I could do this in PySpark? Any leads would be greatly appreciated.&lt;/P&gt;</description>
    <pubDate>Tue, 07 Jun 2022 02:21:48 GMT</pubDate>
    <dc:creator>RiyazAliM</dc:creator>
    <dc:date>2022-06-07T02:21:48Z</dc:date>
    <item>
      <title>Is there a way to CONCAT two dataframes on either of the axis (row/column) and transpose the dataframe in PySpark?</title>
      <link>https://community.databricks.com/t5/data-engineering/is-there-a-way-to-concat-two-dataframes-on-either-of-the-axis/m-p/18550#M12326</link>
      <description>&lt;P&gt;I'm reshaping my dataframe as per requirement and I came across this situation where I'm concatenating 2 dataframes and then transposing them. I've done this previously using pandas and the syntax for pandas goes as below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;import pandas as pd
&amp;nbsp;
df1 = pd.DataFrame(some_dict)
df2 = pd.DataFrame(some_dict)
&amp;nbsp;
new_df = pd.concat( [df1, df2], axis = "column") #stacking the dfs side by side
&amp;nbsp;
trans_df = new_df.transpose() or simply new_df.T&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is there a way I could do this in PySpark? Any leads would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2022 02:21:48 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/is-there-a-way-to-concat-two-dataframes-on-either-of-the-axis/m-p/18550#M12326</guid>
      <dc:creator>RiyazAliM</dc:creator>
      <dc:date>2022-06-07T02:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to CONCAT two dataframes on either of the axis (row/column) and transpose the dataframe in PySpark?</title>
      <link>https://community.databricks.com/t5/data-engineering/is-there-a-way-to-concat-two-dataframes-on-either-of-the-axis/m-p/18551#M12327</link>
      <description>&lt;P&gt;Hi @Kaniz Fatma​&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I no longer see the answer you've posted, but I see you were suggesting to use `union`. As per my understanding, union are used to stack the dfs one upon another with similar schema / column names.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my situation, I have 2 different DataFrames with different columns (and schema) but same number of records. I want to stack them side by side.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For e.g: DF1 has 2 columns(a and b) and 10 rows and DF2 has 3 columns (x,y, and z) with same 10 rows. I want the resultant DataFrame to be with 10 rows and 5 columns (a,b,c,d and e).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you &lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;  &lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2022 06:45:41 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/is-there-a-way-to-concat-two-dataframes-on-either-of-the-axis/m-p/18551#M12327</guid>
      <dc:creator>RiyazAliM</dc:creator>
      <dc:date>2022-06-07T06:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to CONCAT two dataframes on either of the axis (row/column) and transpose the dataframe in PySpark?</title>
      <link>https://community.databricks.com/t5/data-engineering/is-there-a-way-to-concat-two-dataframes-on-either-of-the-axis/m-p/18553#M12329</link>
      <description>&lt;P&gt;Thanks @Kaniz Fatma​, this has solved half of the problem, the other half is that I need to &lt;B&gt;Transpose the pyspark dataframe&lt;/B&gt;. Any help on this one?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2022 08:15:32 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/is-there-a-way-to-concat-two-dataframes-on-either-of-the-axis/m-p/18553#M12329</guid>
      <dc:creator>RiyazAliM</dc:creator>
      <dc:date>2022-06-07T08:15:32Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to CONCAT two dataframes on either of the axis (row/column) and transpose the dataframe in PySpark?</title>
      <link>https://community.databricks.com/t5/data-engineering/is-there-a-way-to-concat-two-dataframes-on-either-of-the-axis/m-p/18555#M12331</link>
      <description>&lt;P&gt;Greatly appreciate the help @Kaniz Fatma​&amp;nbsp;!! &lt;/P&gt;&lt;P&gt;Eventhough I had to make multiple tweaks to the TransposeDF function, it gave me the idea to begin with. Thanks for the prompt response, I was able to wrap-up this issue with in this day! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2022 10:32:11 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/is-there-a-way-to-concat-two-dataframes-on-either-of-the-axis/m-p/18555#M12331</guid>
      <dc:creator>RiyazAliM</dc:creator>
      <dc:date>2022-06-07T10:32:11Z</dc:date>
    </item>
  </channel>
</rss>

