How to prevent Pandas from converting my integers to floats when I merge two dataFrames?

This bug was fixed in pandas v0.19.0.:

Merging will now preserve the dtype of the join keys

but note you can convert all columns in a dataframe to int dtype with:

result = result.astype(int)

This behaviour does still occur if there are unmatched records in the join, and hence NaNs in the results. In this case, you need to change the dtype to the extension type 'Int64' to handle the NaNs:

result = result.astype('Int64')

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)