About 210,000 results
Open links in new tab
  1. 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 …

  2. Specifying number of decimal places in Python - Stack Overflow

    IOW, I third the suggestion to try the decimal module if getting the rounding direction right for halfway cases is important. :) BTW, in Python 2.x, round still rounds halfway cases away from …

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

    Q. 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. What …

  4. python - How to display a float with two decimal places ... - Stack ...

    I have a function taking float arguments (generally integers or decimals with one significant digit), and I need to output the values in a string with two decimal places (5 → 5.00, 5.5 → 5.50, etc)...

  5. python - How to format a float with a maximum number of …

    I need to do some decimal place formatting in python. Preferably, the floating point value should always show at least a starting 0 and one decimal place. Example: Input: 0 Output: 0.0 Values …

  6. Python 3 Float Decimal Points/Precision - Stack Overflow

    In Python 3 however, float(-3.65) returns -3.6499999999999999 which loses its precision. I want to print the list of floats, [-3.6499999999999999, 9.1699999999999999, 1.0] with 2 decimal …

  7. 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...

  8. python - Set decimal precision of a pandas dataframe column with …

    Apr 6, 2021 · I use the '.apply' function to set the data type of the value column to Decimal (Python Decimal library). Once I do this the Value column goes from a 4 decimal place value …

  9. python - Specify format of floats for tick labels - Stack Overflow

    I am trying to set the format to two decimal numbers in a matplotlib subplot environment. Unfortunately, I do not have any idea how to solve this task. To prevent using scientific …

  10. python - How do you display values in a pandas dataframe …

    Aug 19, 2020 · DF['price'] = DF['price'].apply(lambda x: round(x, 2)) However, the problem is that I wish to display everything in 2 decimal places, but values like 0.5 are staying at 1 decimal …