title: Why Pandas Dataframe (and Python) have a strange float-precision decimal value assignment which impacts rounding?
body: <p>Hope anyone can help explain the following behavior and how to fix it</p>
  <p>I have a DataFrame like this:</p>
  <pre><code>l = [[1, 50, 3, 4.003], [1, 50, 4, 5.002], [2, 10, 3, 5.003], [2, 50, 2, 5.004]]
  df = pd.DataFrame(l, columns=[&quot;a&quot;, &quot;b&quot;, &quot;c&quot;,&quot;d&quot;])
  
  df # Output:
      a   b   c   d
  0   1   50  3   4.003
  1   1   50  4   5.002
  2   2   10  3   5.003
  3   2   50  2   5.004
  </code></pre>
  <p>Now if I do a simple sum of column &quot;d&quot; row1 + row2 I should expect a result of <code>9.005</code>, right?
  Well wrong, instead I get <code>9.004999999999999</code>, this is what I do:</p>
  <pre><code>sum = df.loc[0][&quot;d&quot;] + df.loc[1][&quot;d&quot;]
  sum # Output:
  9.004999999999999
  </code></pre>
  <p>This affects the outcome of rounding to 2 decimal points after the sum.</p>
  <p>I did some research on the internet and it might have to do with number of bytes used on the float64 data type but is there a way to overcome this issue?</p>
  <p>By the way when I try the same with regular python variables it does the same thing:</p>
  <pre><code>d0 = 4.003
  d1 = 5.002
  
  d0 + d1 # Output:
  9.004999999999999
  </code></pre>
  <p>The challenge is that if I need to round the results to two decimals I want to get <code>9.01</code> and not <code>9.0</code></p>
  <pre><code>round((d0 + d1), 2) # Output:
  9.0  # It should have been 9.01
  </code></pre>
  <p>So when we have thousands or even millions of records one would have to identify which values are having the point-precision error before summing and rounding to avoid this issue?, it will be very impractical, any other suggestions?</p>