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

Round on DataFrames transform perfect number in decimals [duplicate]

$
0
0

I am currently working with pandas version 2.2.0 and I have the following issue when rounding my DataFrame:

pd.DataFrame({"value": [26586491.0]}).round(15)["value"].iloc[0][2]: 26586490.999999996

This is annoying because there might be situations where we want to compare the exact value. Using numpy directly gives similar issues.Any idea what is wrong here ? I guess the problem comes from how pandas stores floats but is there a way to avoid such behavior ?


Viewing all articles
Browse latest Browse all 23131

Trending Articles



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