<?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 Comparing schemas of two dataframes in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/comparing-schemas-of-two-dataframes/m-p/39180#M26887</link>
    <description>&lt;P&gt;So I was comparing schemas of two different dataframe using this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;gt;&amp;gt;&amp;gt; df1.schema == df2.schema
Out: False&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the thing is, both the schemas are completely equal.&lt;/P&gt;&lt;P&gt;When digging deeper I realized that some of the StructFields() that should have been equal have different metadata property&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{'name': 'customer_id', 'dataType': StringType(), 'nullable': True, 'metadata': {}}
{'name': 'customer_id', 'dataType': StringType(), 'nullable': True, 'metadata': {'scale': 0}}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What does this metadata property do?&lt;/P&gt;&lt;P&gt;Edit:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;gt;&amp;gt;&amp;gt; all(str(x) == str(y) for x, y in zip(df1.schema, df2.schema))
Out: True&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 05 Aug 2023 11:14:12 GMT</pubDate>
    <dc:creator>dream</dc:creator>
    <dc:date>2023-08-05T11:14:12Z</dc:date>
    <item>
      <title>Comparing schemas of two dataframes</title>
      <link>https://community.databricks.com/t5/data-engineering/comparing-schemas-of-two-dataframes/m-p/39180#M26887</link>
      <description>&lt;P&gt;So I was comparing schemas of two different dataframe using this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;gt;&amp;gt;&amp;gt; df1.schema == df2.schema
Out: False&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the thing is, both the schemas are completely equal.&lt;/P&gt;&lt;P&gt;When digging deeper I realized that some of the StructFields() that should have been equal have different metadata property&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{'name': 'customer_id', 'dataType': StringType(), 'nullable': True, 'metadata': {}}
{'name': 'customer_id', 'dataType': StringType(), 'nullable': True, 'metadata': {'scale': 0}}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What does this metadata property do?&lt;/P&gt;&lt;P&gt;Edit:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;gt;&amp;gt;&amp;gt; all(str(x) == str(y) for x, y in zip(df1.schema, df2.schema))
Out: True&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Aug 2023 11:14:12 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/comparing-schemas-of-two-dataframes/m-p/39180#M26887</guid>
      <dc:creator>dream</dc:creator>
      <dc:date>2023-08-05T11:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing schemas of two dataframes</title>
      <link>https://community.databricks.com/t5/data-engineering/comparing-schemas-of-two-dataframes/m-p/39188#M26888</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/84686"&gt;@dream&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;In this case, you can go with &lt;STRONG&gt;dataframe.dtypes&amp;nbsp;&lt;/STRONG&gt;for comparing the schema or datatypes for two dataframe&lt;BR /&gt;Metadata store information about column properties&lt;/P&gt;</description>
      <pubDate>Sat, 05 Aug 2023 14:56:42 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/comparing-schemas-of-two-dataframes/m-p/39188#M26888</guid>
      <dc:creator>Ajay-Pandey</dc:creator>
      <dc:date>2023-08-05T14:56:42Z</dc:date>
    </item>
  </channel>
</rss>

