furkan çelik
furkan çelik

Reputation: 29

Python df to database float numbers unexpectedly rounded

I have dataframe that contains 26 columns. the column types are float64, int64, datetime and object. I insert this df to database. however the float64 columns unexpectedly rounded as i see in the database.

'''

    query = config['query']['insert_output_query']  
    #query = insert into schema.table values(:1,:2,:3,...,:25,:26)
    db_cursor.executemany(query, df.values.tolist())
    db_connection.commit()

'''

i succesfully inserted the df to database but how i can handle unexpectedly rounding problem.

Thanks.

Upvotes: 1

Views: 388

Answers (1)

furkan çelik
furkan çelik

Reputation: 29

i find the problem. i created the table column as float but as i understand if i would not assignedthe number of bits, a column which is type float keeps 1 digit. but when i assigned the column type as float(64) it keeps the decimal and fractional part.

Upvotes: 1

Related Questions