0

I have a dataframe with float columns, some values in which are NaN. I would like to write this dataframe to a snowflake database using the simple df.to_sql() function provided by pandas.

Here is the issue: snowflake only accepts NaN (not NULL) as a float value. to_sql(), on the other hand, tries to uses the value NULL when it constructs the sql statement as mentioned in this SO thread.

I don't see a way to override how to_sql tries to pass null values to the database in the docs for the to_sql function.

Can this value be overwritten (for FLOAT columns, specifically)? Otherwise I will probably have to manually construct these sql statements.

2
  • I'm not clear on the requirement. The float type in Snowflake supports both NaN and NULL values. Commented Dec 2, 2020 at 18:39
  • Have you looked at the write_pandas() function in Snowflake Python connector? Are you already using the pd_writer value in your to_sql() method? Either might handle NaN and NULL better for you. Commented Dec 2, 2020 at 23:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.