About 497,000 results
Open links in new tab
  1. How to round to 2 decimals with Python? - Stack Overflow

    Dec 9, 2013 · If you just want to print the rounded result out, you can use the f-strings introduced since Python 3.6. The syntax is the same as str.format() 's format string syntax, except you put a f in front …

  2. python - Limiting floats to two decimal points - Stack Overflow

    Jan 19, 2009 · These conversions occur in many different places: str () on floats and complex numbers; the float and complex constructors; numeric formatting; serializing and de-serializing floats and …

  3. python - How to round a numpy array? - Stack Overflow

    I have a numpy array, something like below: data = np.array([ 1.60130719e-01, 9.93827160e-01, 3.63108206e-04]) and I want to round each element to two decimal places. How can I do so?

  4. round() doesn't seem to be rounding properly - Stack Overflow

    The documentation for the round() function states that you pass it a number, and the positions past the decimal to round. Thus it should do this: n = 5.59 round(n, 1) # 5.6 But, in actuality, good...

  5. rounding - round down to 2 decimal in python - Stack Overflow

    I need to round down and it should be two decimal places. Tried the following, a = 28.266 print round(a, 2) 28.27 But the expected value is 28.26 only.

  6. python - round a single column in pandas - Stack Overflow

    Oct 1, 2014 · .round () is a pandas method and it applies to the output format rather than the underlying value. If you have floats with many decimal places you can instead apply the Python function round …

  7. How to round a Python Decimal to 2 decimal places?

    May 10, 2014 · 20 I've got a python Decimal (a currency amount) which I want to round to two decimal places. I tried doing this using the regular round () function. Unfortunately, this returns a float, which …

  8. How can I format a decimal to always show 2 decimal places?

    In a fixed-point application with two decimal places, some inputs have many places and need to be rounded. Others are not supposed to have excess digits and need to be validated.

  9. python - Fixed digits after decimal with f-strings - Stack Overflow

    Is there an easy way with Python f-strings to fix the number of digits after the decimal point? (Specifically f-strings, not other string formatting options like .format or %) For example, let's s...

  10. Round up to second decimal place in Python - Stack Overflow

    55 Python includes the round() function which lets you specify the number of digits you want. From the documentation: round(x[, n]) Return the floating point value x rounded to n digits after the decimal …