Closed Newbee25 closed 7 months ago
You can use an input type handler to transform the np.NaN
values to whatever value you choose. Or you can use the method you suggested. Both should work fine. The value None
is definitely recognized as a null value. The value NaN
is also supported -- but only for insert into a binary_double or binary_float column. NUMBER columns do not support those values. Can you provide the full code that failed when trying with a None
value? If you still see a problem I'll give it a try.
This has been confirmed to work:
import math
def input_type_handler(cursor, value, arraysize):
if isinstance(value, float):
return cursor.var(oracledb.DB_TYPE_NUMBER, arraysize=arraysize,
inconverter=lambda x: None if math.isnan(x) else x)
db_connection.inputtypehandler = input_type_handler
Closing - no activity.
I'm trying to bulk load a dataframe into an oracle table. The following error occurs:
No error occurs when the records are inserted one by one.
Oracle table:
Python Code
Please note the floats
NaN
must be inserted asnull
values to the table.I attempted
df['Weight'].fillna(float('NaN'), inplace=True)
anddf['Year'].fillna(float('NaN'), inplace=True)
I also attempted to replaceNaN
withNone
.It seems it is not recognizing None and NaN as valid types.
Is issue a possible bug?
I'm using the thick client mode and it is calling init_oracle_client()
Version