<?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 Re: Confusion in string comparison in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/confusion-in-string-comparison/m-p/7842#M3610</link>
    <description>&lt;P&gt;@Saswata Dutta​&amp;nbsp;Welcome to the club. Wish you a great time with Spark.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The filter API always need the parameters in parenthesis for equality checks. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;//Filter multiple condition
df.filter( (df.state  == "OH") &amp;amp; (df.gender  == "M") ) \
    .show(truncate=False)  &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In your case, you missed the bracket in the condition. The below code should work. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;df.filter((F.col("state").isNull())| (F.col("state")=="")| (F.col("state").contains(""))| (F.col("number").isNull())).show()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Please try and see if this helps. &lt;/P&gt;</description>
    <pubDate>Mon, 13 Mar 2023 16:36:48 GMT</pubDate>
    <dc:creator>pvignesh92</dc:creator>
    <dc:date>2023-03-13T16:36:48Z</dc:date>
    <item>
      <title>Confusion in string comparison</title>
      <link>https://community.databricks.com/t5/data-engineering/confusion-in-string-comparison/m-p/7840#M3608</link>
      <description>&lt;P&gt;Hello expert&lt;/P&gt;&lt;P&gt;I am new to spark. I am using same price of code but getting different results&lt;/P&gt;&lt;P&gt;When i am using below piece of code, i am getting error&lt;/P&gt;&lt;P&gt;py4j.Py4JException: Method or([class java.lang.String]) does not exist&lt;/P&gt;&lt;P&gt;df.filter(F.col("state").isNull()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;| &lt;B&gt;F.col("state")==""&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;| F.col("state").contains("")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;| F.col("number").isNull()).show()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However when i am using below piece of code, its working fine&lt;/P&gt;&lt;P&gt;df.withColumn("state",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;F.when(&lt;B&gt;F.col("state")==""&lt;/B&gt;,None)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.otherwise(F.col("state"))).show()&lt;/P&gt;&lt;P&gt;The same &lt;B&gt;F.col("state")=="" &lt;/B&gt;code is working in one place but not working in other&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2023 00:49:40 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/confusion-in-string-comparison/m-p/7840#M3608</guid>
      <dc:creator>Sas</dc:creator>
      <dc:date>2023-03-13T00:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: Confusion in string comparison</title>
      <link>https://community.databricks.com/t5/data-engineering/confusion-in-string-comparison/m-p/7841#M3609</link>
      <description>&lt;P&gt;Hi @Saswata Dutta​&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please use blow code this will work-&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;df.filter((F.col("state").isNull())| (F.col("state")=="")| (F.col("state").contains(""))| (F.col("number").isNull())).show()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2023 13:14:30 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/confusion-in-string-comparison/m-p/7841#M3609</guid>
      <dc:creator>Ajay-Pandey</dc:creator>
      <dc:date>2023-03-13T13:14:30Z</dc:date>
    </item>
    <item>
      <title>Re: Confusion in string comparison</title>
      <link>https://community.databricks.com/t5/data-engineering/confusion-in-string-comparison/m-p/7842#M3610</link>
      <description>&lt;P&gt;@Saswata Dutta​&amp;nbsp;Welcome to the club. Wish you a great time with Spark.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The filter API always need the parameters in parenthesis for equality checks. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;//Filter multiple condition
df.filter( (df.state  == "OH") &amp;amp; (df.gender  == "M") ) \
    .show(truncate=False)  &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In your case, you missed the bracket in the condition. The below code should work. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;df.filter((F.col("state").isNull())| (F.col("state")=="")| (F.col("state").contains(""))| (F.col("number").isNull())).show()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Please try and see if this helps. &lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2023 16:36:48 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/confusion-in-string-comparison/m-p/7842#M3610</guid>
      <dc:creator>pvignesh92</dc:creator>
      <dc:date>2023-03-13T16:36:48Z</dc:date>
    </item>
    <item>
      <title>Re: Confusion in string comparison</title>
      <link>https://community.databricks.com/t5/data-engineering/confusion-in-string-comparison/m-p/7843#M3611</link>
      <description>&lt;P&gt;Hi @Saswata Dutta​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your question! To assist you better, please take a moment to review the answer and let me know if it best fits your needs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help us select the best solution by clicking on "Select As Best" if it does.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your feedback will help us ensure that we are providing the best possible service to you. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Mar 2023 07:35:10 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/confusion-in-string-comparison/m-p/7843#M3611</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-03-18T07:35:10Z</dc:date>
    </item>
  </channel>
</rss>

