How can we convert pandas NaN to SQL NULL?

shubham_rai
shubham_rai Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 1 ✭✭✭

I am pushing DataFrame from Dataiku to PostgreSQL database using SQLExecutor2 library. Is there a way I can convert pandas 'NaN' to SQL NULL value?

I tried converting NaN to None also but it's not working.

Then I used psychopg2 library to convert NaN to NULL, its working fine until conversion but while writing SQL to database it fails.

I printed SQL string to check, in string instead of NULL, it is passing psychopg object <psycopg2.extensions.AsIs object at 0x7f837256dd80> This may be the possible reason of failure.


Operating system used: Linux


Operating system used: Linux

Answers

Setup Info
    Tags
      Help me…