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.

Maile Cupo
  • 636
  • 1
  • 10
  • 26
  • I'm not clear on the requirement. The float type in Snowflake supports both NaN and NULL values. – Greg Pavlik Dec 02 '20 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. – Mike Walton Dec 02 '20 at 23:03

0 Answers0