<?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: Why does df.dropna(how=&amp;quot;all&amp;quot;) fail when there is a . in a column name? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/why-does-df-dropna-how-quot-all-quot-fail-when-there-is-a-in-a/m-p/121236#M46385</link>
    <description>&lt;P&gt;but you actually renamed the column and put an underscore '_' instead of a dot '.'&lt;/P&gt;</description>
    <pubDate>Mon, 09 Jun 2025 09:31:37 GMT</pubDate>
    <dc:creator>Abhimanyu</dc:creator>
    <dc:date>2025-06-09T09:31:37Z</dc:date>
    <item>
      <title>Why does df.dropna(how="all") fail when there is a . in a column name?</title>
      <link>https://community.databricks.com/t5/data-engineering/why-does-df-dropna-how-quot-all-quot-fail-when-there-is-a-in-a/m-p/119714#M45956</link>
      <description>&lt;P&gt;I'm working in a Databricks notebook and using Spark to query a Delta table. Here's the code I ran:&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;DIV class=""&gt;&lt;SPAN&gt;&lt;SPAN&gt;df = spark.sql(&lt;SPAN class=""&gt;"select * from catalog.schema.table") df = df.dropna(how=&lt;SPAN class=""&gt;"all") display(df)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV class=""&gt;&lt;P&gt;This works fine &lt;STRONG&gt;unless the DataFrame has a column name that contains a dot (.), like Disc.. When such a column exists, the dropna(how="all") line fails with a syntax error saying:&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;DIV class=""&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;Syntax &lt;SPAN class=""&gt;error in attribute name: Disc.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;P&gt;I understand that . has a special meaning in Spark SQL (used for nested fields), but why does this cause an issue with a general dropna() operation that doesn’t reference column names explicitly?&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;Is this a known limitation or bug?&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;What's the best way to handle such cases where column names have dots?&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Should I always rename such columns before transformation?&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 20 May 2025 09:39:44 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/why-does-df-dropna-how-quot-all-quot-fail-when-there-is-a-in-a/m-p/119714#M45956</guid>
      <dc:creator>Abhimanyu</dc:creator>
      <dc:date>2025-05-20T09:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: Why does df.dropna(how="all") fail when there is a . in a column name?</title>
      <link>https://community.databricks.com/t5/data-engineering/why-does-df-dropna-how-quot-all-quot-fail-when-there-is-a-in-a/m-p/119735#M45961</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/141356"&gt;@Abhimanyu&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;Yeah Actually in spark,&lt;STRONG&gt; '.'(dot)&lt;/STRONG&gt; in columns is used for StructType by which the nested object can be accessed.&lt;BR /&gt;But definitely You can rename thE columns dynamically whichever has '.' in it.&lt;BR /&gt;Attached few screenshots for your reference that demonstrates the dropna(how='all') functionality for&lt;STRONG&gt; '.'&lt;/STRONG&gt; columns without manual work&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MujtabaNoori_0-1747745580276.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/16968i63F32BD767A6015B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MujtabaNoori_0-1747745580276.png" alt="MujtabaNoori_0-1747745580276.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MujtabaNoori_1-1747745586077.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/16969i2320C78FAF70BDB2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MujtabaNoori_1-1747745586077.png" alt="MujtabaNoori_1-1747745586077.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;CODE FOR YOUR REFERENCE&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;cols &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; []&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;for&lt;/SPAN&gt;&lt;SPAN&gt; col &lt;/SPAN&gt;&lt;SPAN&gt;in&lt;/SPAN&gt;&lt;SPAN&gt; df.columns:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt; &lt;SPAN&gt;'.'&lt;/SPAN&gt; &lt;SPAN&gt;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;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 20 May 2025 12:55:54 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/why-does-df-dropna-how-quot-all-quot-fail-when-there-is-a-in-a/m-p/119735#M45961</guid>
      <dc:creator>MujtabaNoori</dc:creator>
      <dc:date>2025-05-20T12:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: Why does df.dropna(how="all") fail when there is a . in a column name?</title>
      <link>https://community.databricks.com/t5/data-engineering/why-does-df-dropna-how-quot-all-quot-fail-when-there-is-a-in-a/m-p/121236#M46385</link>
      <description>&lt;P&gt;but you actually renamed the column and put an underscore '_' instead of a dot '.'&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jun 2025 09:31:37 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/why-does-df-dropna-how-quot-all-quot-fail-when-there-is-a-in-a/m-p/121236#M46385</guid>
      <dc:creator>Abhimanyu</dc:creator>
      <dc:date>2025-06-09T09:31:37Z</dc:date>
    </item>
  </channel>
</rss>

