<?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: Python Notebook: writing in existing table error due to datatype Null in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-writing-in-existing-table-error-due-to-datatype/m-p/4398643#M7017</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/784051"&gt;@Testaaaaaa&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Thanks for reaching MS Fabric community support.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please refer to below code to ensure that Nan values are handled properly:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;df = pd.DataFrame(all_items)

# Replace NaN with None for all columns
df = df.fillna(None)

# Replace NaN in any specific column with a placeholder value (for example, 0 for integers or a default date for datetime columns)
df['some_column'] = df['some_column'].fillna(0).astype(int)
df['Insert_Datetime'] = pd.to_datetime(today[0:-6], errors='coerce').fillna(pd.Timestamp('2025-01-01'))

# Drop columns that are completely NaN
df = df.dropna(axis=1, how='all')

# Check the data before writing
print(df.info())  # Check for any remaining NaN or None values

if not df.empty:
    table_path = f"{lakehouse_details_abfsPath}/Tables/{lakehouse_table}"
    write_deltalake(table_path, df, mode='append', schema_mode='merge', engine='rust', storage_options=storage_options)
    print(f"Number of records added in {lakehouse_table}: {len(df)}")
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Prashanth Are&lt;/P&gt;
&lt;P&gt;MS fabric community support&lt;/P&gt;</description>
    <pubDate>Thu, 06 Feb 2025 17:46:37 GMT</pubDate>
    <dc:creator>v-prasare</dc:creator>
    <dc:date>2025-02-06T17:46:37Z</dc:date>
    <item>
      <title>Python Notebook: writing in existing table error due to datatype Null</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-writing-in-existing-table-error-due-to-datatype/m-p/4397270#M6975</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a existing table which was created (a few days ago) after pulling the last 30 days of activityEvents from PowerBI REST API.&lt;/P&gt;&lt;P&gt;I am facing issues when incrementally loading new data du to the following error:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Python Notebook: writing in existing table error due to datatype Null&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following code which I though would take care of this issue:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;df = pd.DataFrame(all_items)
# Remove all columns with Null type
df = df.dropna(axis=1, how='all')
if not df.empty:
    df['Insert_Datetime'] = today[0:-6]
    table_path = f"{lakehouse_details_abfsPath}/Tables/{lakehouse_table}" 
    write_deltalake(table_path, df, mode='append', schema_mode='merge', engine='rust', storage_options=storage_options)
    print(f"        Number of records added in {lakehouse_table}: {len(df)}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When query the data, I can't find columns with only NaN value.&lt;/P&gt;&lt;P&gt;I've tried to change NaN to None or other values to see if Nan was the issue but it doesn't seem so, especially after dropping columns being dropped if Nan value only.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any tips on how I should go about?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2025 01:12:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-writing-in-existing-table-error-due-to-datatype/m-p/4397270#M6975</guid>
      <dc:creator>Testaaaaaa</dc:creator>
      <dc:date>2025-02-06T01:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: Python Notebook: writing in existing table error due to datatype Null</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-writing-in-existing-table-error-due-to-datatype/m-p/4398643#M7017</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/784051"&gt;@Testaaaaaa&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Thanks for reaching MS Fabric community support.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please refer to below code to ensure that Nan values are handled properly:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;df = pd.DataFrame(all_items)

# Replace NaN with None for all columns
df = df.fillna(None)

# Replace NaN in any specific column with a placeholder value (for example, 0 for integers or a default date for datetime columns)
df['some_column'] = df['some_column'].fillna(0).astype(int)
df['Insert_Datetime'] = pd.to_datetime(today[0:-6], errors='coerce').fillna(pd.Timestamp('2025-01-01'))

# Drop columns that are completely NaN
df = df.dropna(axis=1, how='all')

# Check the data before writing
print(df.info())  # Check for any remaining NaN or None values

if not df.empty:
    table_path = f"{lakehouse_details_abfsPath}/Tables/{lakehouse_table}"
    write_deltalake(table_path, df, mode='append', schema_mode='merge', engine='rust', storage_options=storage_options)
    print(f"Number of records added in {lakehouse_table}: {len(df)}")
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Prashanth Are&lt;/P&gt;
&lt;P&gt;MS fabric community support&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2025 17:46:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-writing-in-existing-table-error-due-to-datatype/m-p/4398643#M7017</guid>
      <dc:creator>v-prasare</dc:creator>
      <dc:date>2025-02-06T17:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: Python Notebook: writing in existing table error due to datatype Null</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-writing-in-existing-table-error-due-to-datatype/m-p/4402883#M7106</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/784051"&gt;@Testaaaaaa&lt;/a&gt;,&amp;nbsp;As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for your issue worked? or let us know if you need any further assistance here?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Prashanth Are&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;MS Fabric community support&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this post helps, then please consider&amp;nbsp;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly and give&amp;nbsp;&lt;STRONG&gt;Kudos&lt;/STRONG&gt;&amp;nbsp;if helped you resolve your query&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2025 12:17:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-writing-in-existing-table-error-due-to-datatype/m-p/4402883#M7106</guid>
      <dc:creator>v-prasare</dc:creator>
      <dc:date>2025-02-10T12:17:59Z</dc:date>
    </item>
    <item>
      <title>Re: Python Notebook: writing in existing table error due to datatype Null</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-writing-in-existing-table-error-due-to-datatype/m-p/4404680#M7126</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for offering your help however this hasn't fixed the issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I ended up concatenating the data from the existing table with the new data as a workaround.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2025 09:14:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-writing-in-existing-table-error-due-to-datatype/m-p/4404680#M7126</guid>
      <dc:creator>Testaaaaaa</dc:creator>
      <dc:date>2025-02-11T09:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: Python Notebook: writing in existing table error due to datatype Null</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-writing-in-existing-table-error-due-to-datatype/m-p/4408366#M7178</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/784051"&gt;@Testaaaaaa&lt;/a&gt;, Thanks for confirmation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you resolved this with workaround, Can you please mark your post as answer so that other users who are facing similar challenges will able to resolve.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Prashanth Are&lt;/P&gt;
&lt;P&gt;MS Fabric community support&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2025 11:30:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-writing-in-existing-table-error-due-to-datatype/m-p/4408366#M7178</guid>
      <dc:creator>v-prasare</dc:creator>
      <dc:date>2025-02-13T11:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: Python Notebook: writing in existing table error due to datatype Null</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-writing-in-existing-table-error-due-to-datatype/m-p/4413383#M7264</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/784051"&gt;@Testaaaaaa&lt;/a&gt;,&amp;nbsp;As we haven’t heard back from you, we wanted to kindly follow up to check if your still facing same issue or let me know if you need additional help here.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Prashanth Are&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;MS Fabric community support&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this post helps, then please consider&amp;nbsp;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly and give&amp;nbsp;&lt;STRONG&gt;Kudos&lt;/STRONG&gt;&amp;nbsp;if helped you resolve your query&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2025 08:44:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-writing-in-existing-table-error-due-to-datatype/m-p/4413383#M7264</guid>
      <dc:creator>v-prasare</dc:creator>
      <dc:date>2025-02-17T08:44:28Z</dc:date>
    </item>
    <item>
      <title>Re: Python Notebook: writing in existing table error due to datatype Null</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-writing-in-existing-table-error-due-to-datatype/m-p/4417381#M7339</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/784051"&gt;@Testaaaaaa&lt;/a&gt;, As we haven’t heard back from you, we wanted to kindly follow up to check if your still facing same issue or let me know if you need additional help here.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Prashanth Are&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;MS Fabric community support&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this post helps, then please consider&amp;nbsp;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly and give&amp;nbsp;&lt;STRONG&gt;Kudos&lt;/STRONG&gt;&amp;nbsp;if helped you resolve your query&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2025 09:10:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-writing-in-existing-table-error-due-to-datatype/m-p/4417381#M7339</guid>
      <dc:creator>v-prasare</dc:creator>
      <dc:date>2025-02-19T09:10:22Z</dc:date>
    </item>
  </channel>
</rss>

