I am trying to insert all the data of a df into a table in an Oracle db. Before inserting the data into the table, I convert the df values into a list:
df_list = df.values.tolist()
but after some values that in the df were int64, become float numbers in the list, so I cannot insert the values in my db because those numbers are not int anymore. Is there a way to avoid this to happen? Is there a reason why is this happening?
Thank you in advance for your help!
CodePudding user response:
Probably you have some Nan values in the values column. And it makes Int values float.
To solve it. Before getting the list you can fillna(0, inplace=True)
the column and then get the list.
for example:
df.fillna(0, inplace=True) #you can change it some other integer which you do not need
df.values = df.values.apply(int)
df_list = df.values.unique().tolist()
df_list.remove(0)