IBM / dse-decision-optimization-utilities

A Python package with various utilities that speed-up development of Decision Optimization projects in Watson Studio. Implements common tasks and provides best-practice guidelines to architect DO projects.
Apache License 2.0
4 stars 7 forks source link

DB2-Cloud ForeignKey fails with nan #49

Closed victorterpstra closed 1 year ago

victorterpstra commented 2 years ago

DB2-Cloud foreign-keys seems to not allow nan values in Pandas DataFrames. For example, we have a string productGroupName that can be nan. SQLite has no problem. Note that the Column does not specify nullable, which defaults to True.

TODO: Find out how to properly set in combination with DB2 Cloud.

Work-around:

victorterpstra commented 1 year ago

Seems in one instance this problem is caused to the fact that the 'NaN' value is a string column with values 'nan'. SQLite worked fine, even the row-by-row insert into DB2 Cloud worded correctly, i.e. the resulting value in the DB table was a NULL. However, the df.to_sql() fails. Added a fix in ScebarioDbTable to convert string 'nan' to None.

Fixed in v0.5.4.6b0