About 2,680,000 results
Open links in new tab
  1. round () doesn't seem to be rounding properly - Stack Overflow

    If you get this error NameError: global name 'ROUND_UP' is not defined you need to import your rounding function: from decimal import Decimal, ROUND_UP. Other rounding functions. Your …

  2. rounding - round function not working in python - Stack Overflow

    def round(x, n): return round(x, n) Even if you fix your function call, you'll most likely end up with RuntimeError due to maximum recursion. Rename your function to something other than round .

  3. Python’s round() Function Doesn’t do What You Think

    Jun 5, 2020 · We can fix this by defining a new rounding function: def normal_round(number): """Round a float to the nearest integer.""" return int(number + 0.5) Extended Solution. We can …

  4. python - Pandas round is not working for DataFrame - Stack Overflow

    Try running either df = df.astype('float64') or df = df.apply(pd.to_numeric, errors='coerce') and then try rounding after that. Try to cast to float type: For those who might think "but my column …

  5. How to Round Numbers in Python

    Dec 7, 2024 · You can round numbers to specific decimal places using Python’s round() function with a second argument. Different rounding strategies can be applied using Python’s decimal …

  6. Troubleshooting Rounding Issues with round() in Python 3

    Rounding issues can occur when using the round() function in Python due to floating-point precision and the “round half to even” rule. To troubleshoot these issues, the decimal module …

  7. round() function in Python - GeeksforGeeks

    Aug 7, 2024 · The `round()` function in Python is used to round numbers. It takes two parameters: the number to be rounded and, optionally, the number of decimal places. If no decimal places …

  8. How to Use the round() Function in Python? - Python Guides

    Jan 9, 2025 · Learn how to use Python's `round()` function to round numbers to the nearest integer or specified decimal places. This tutorial includes syntax, examples, and tips!

  9. New to Python. Is this an inconsistency of the 'round()' function?

    Mar 18, 2023 · https://docs.python.org/3/library/functions.html#round. The behavior of round() for floats can be surprising: for example, round(2.675, 2) gives 2.67 instead of the expected 2.68. …

  10. python - Round() not working - Stack Overflow

    Feb 22, 2018 · round doesn't help because its output is still a float. You can't really fix this in any simple way, as it is an artefact of binary math. Some options are: fix the displayed precision of …

Refresh