Forum Discussion
Testaaaaaa
1 year agoFrequent Visitor
Python Notebook: writing in existing table error due to datatype Null
Hi All, I have a existing table which was created (a few days ago) after pulling the last 30 days of activityEvents from PowerBI REST API. I am facing issues when incrementally loading new data ...
- 1 year ago
Hello,
Thank you for offering your help however this hasn't fixed the issue.
I ended up concatenating the data from the existing table with the new data as a workaround.
v-prasare
1 year agoCommunity Support
Hi Testaaaaaa,
Thanks for reaching MS Fabric community support.
please refer to below code to ensure that Nan values are handled properly:
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)}")
Thanks,
Prashanth Are
MS fabric community support
Testaaaaaa
1 year agoFrequent Visitor
Hello,
Thank you for offering your help however this hasn't fixed the issue.
I ended up concatenating the data from the existing table with the new data as a workaround.