Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23276

Pandas pd.read_csv(float_precision='round_trip') - still getting rounding

$
0
0

I have a .txt file. I have opened it in Notepad++ and verified one of the columns has float numbers i.e. 1519.75, 1519.25.

What do I need to do in order to avoid rounding? I have other files which work fine, but not this one.

My code uses below:

pd.set_option('display.float_format', '{:.2f}'.format)raw_df = pd.read_csv(file, sep='\t', float_precision='round_trip')

I have tried using pd.set_option as well as pd.read_csv with float_precision = 'round_trip', but the raw_df output will show the values as 1519.8, 1519.2


Viewing all articles
Browse latest Browse all 23276

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>