I have a field ID
, in MySQL Workbench it's Bigint(20)
type, and if I query in the workbench, it looks like this:
ID
1111111111
2222222222
3333333333
...
If I use pandas.read_sql()
then print out this column, it looks like this:
ID
1.111111e+09
2.222222e+09
3.333333e+09
...
and by checking df.dtypes
, this columns is float64
type,
if I try to convert it to str
by using: df['ID'] = df['ID'].astype('str')
, this column will become like this:
ID
1111111111.0
2222222222.0
3333333333.0
I'm confused... I thought the Bigint(20)
after read_sql()
will become int64
, but why here it becomes float64
, is there a way I can just converted it to int64
or str
and it looks like 1111111111
(without the float .0
?)
I also tried df['ID'] = df['ID'].astype('int64')
, but it gave me error ValueError: Cannot convert non-finite values (NA or inf) to integer
Can someone help please... Thanks.