About 199,000 results
Open links in new tab
  1. Safest way to convert float to integer in python? - Stack Overflow

    Aug 2, 2010 · Python's math module contain handy functions like floor & ceil. These functions take a floating point number and return the nearest integer below or above it. …

  2. floating point - Python float to int conversion - Stack Overflow

    77 This question already has answers here: Safest way to convert float to integer in python? (9 answers) Is floating-point math broken? (36 answers)

  3. python - How do I parse a string to a float or int? - Stack Overflow

    Dec 19, 2008 · For the reverse, see Convert integer to string in Python and Converting a float to a string without rounding it. Please instead use How can I read inputs as numbers? to close …

  4. python - Convert floats to ints in Pandas? - Stack Overflow

    Jan 22, 2014 · parameter convert_float will convert "integral floats to int (i.e., 1.0 –> 1)", but take care with corner cases like NaN's. This parameter is only available in read_excel

  5. python - Round number to nearest integer - Stack Overflow

    The OP's example use-case is where the quantity is a positive float, doesn't care about corner-cases, F-P inexactness, and we only need to care about carrying 3 (or maybe 4) decimal …

  6. python - Pandas: ValueError: cannot convert float NaN to integer ...

    Nov 16, 2017 · 43 ValueError: cannot convert float NaN to integer From v0.24, you actually can. Pandas introduces Nullable Integer Data Types which allows integers to coexist with NaNs. …

  7. How to convert int to float in python? - Stack Overflow

    Nov 27, 2015 · float_version = float(int_version) The reason you are getting 0 is that Python 2 returns an integer if the mathematical operation (here a division) is between two integers. So …

  8. Convert Pandas column containing NaNs to dtype `int`

    Jan 22, 2014 · As this is a python frontend for code running on a jvm, it requires type safety and using float instead of int is not an option. I worked around the issue by wrapping the pandas …

  9. How to convert a float string to an integer in python 3

    Actually int() function expects an integer string or a float, but not a float string. If a float string is given you need to convert it to float first then to int as:

  10. python - How do I convert all of the items in a list to floats? - Stack ...

    632 [float(i) for i in lst] to be precise, it creates a new list with float values. Unlike the map approach it will work in py3k.