How can I round up a number to the second decimal place in python? For example:
0.022499999999999999
Should round up to 0.03<
The python round function could be rounding the way not you expected.
You can be more specific about the rounding method by using Decimal.quantize
eg.
from decimal import Decimal, ROUND_HALF_UP
res = Decimal('0.25').quantize(Decimal('0.0'), rounding=ROUND_HALF_UP)
print(res)
# prints 0.3
More reference:
https://gist.github.com/jackiekazil/6201722