Skip to main content
Solved

Empty values load differently in Python SDK and DB-Extractor


Hi, everyone

I'm trying to load sequences using Python SDK by inserting dataframes. In the dataframe, I have some columns with NaN and numeric values. 

Dataframe: 

 

and when loading NaN values, they are uploaded as 'null'. I've tried replacing them with empty strings, but due to the column definitions, if I have numeric values, the column's data type must be Double or Long, and conflicts arise when encountering empty strings.

This is the code to load a sequence:

 

Results in CDF using Python SDK:

 

However, when loading the sequence via DB-Extractor, empty strings are uploaded as such and not as 'null'

 

Is there any way to load via SDK so that NaN values are uploaded as empty and not 'null'? 

 

Regards,

Karina Saylema

@Aditya Kotiyal  @HanishSharma  @Jason Dressel  @Jairo Salaya @Liliana Sierra 

 

Best answer by Jason Dressel

@Karina Saylema I think you can change the dtype of the column or create a new string column based on the double column of the pandas DataFrame.

View original
Did this topic help you find an answer to your question?

5 replies

Forum|alt.badge.img
  • Seasoned Practitioner
  • 282 replies
  • March 28, 2024

@Karina Saylema I believe you would run the following code on your input Dataframe before uploading to CDF:  Essentially replace the NaN’s with ‘’ (empty string).
Let me know if this works :).

-Jason

df.fillna('', inplace=True)

Hi, I tried filling the NaNs with empty values, but it conflicts when there are numeric values in the same column because it encounters the restriction that all elements in the column must be of the same type. I got this error when filling Nan with empty strings:

 


Forum|alt.badge.img
  • Seasoned Practitioner
  • 282 replies
  • Answer
  • March 29, 2024

@Karina Saylema I think you can change the dtype of the column or create a new string column based on the double column of the pandas DataFrame.


Dilini Fernando
Seasoned Practitioner
Forum|alt.badge.img+2
  • Seasoned Practitioner
  • 671 replies
  • April 16, 2024

Hi @Karina Saylema,

Have you had a chance to try out Jason's suggestion?


Hi Jason,Dilini,

I already tried it and everything worked fine, thank you very much for your help :). 


Reply


Cookie Policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings