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

  2. Checking if a string can be converted to float in Python

    Apr 10, 2009 · TL;DR: If your input is mostly strings that can be converted to floats, the try: except: method is the best native Python method. If your input is mostly strings that cannot be converted to …

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

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

  4. Convert string (in scientific notation) to float - Stack Overflow

    I have tried many different things for converting the concs string into a float, but it doesn't seem to like the fact that the concs are in scientific notation... is there a way to turn the concs values into a float?

  5. python - Converting strings to floats in a DataFrame - Stack Overflow

    May 30, 2017 · How to covert a DataFrame column containing strings and NaN values to floats. And there is another column whose values are strings and floats; how to convert this entire column to floats.

  6. How can I convert a string with dot and comma into a float in Python

    Jul 9, 2011 · 157 How can I convert a string like 123,456.908 to float 123456.908 in Python? For int s, see How to convert a string to a number if it has commas in it as thousands separators?, although …

  7. python - Convert floating point number to a certain precision, and then ...

    Mar 7, 2013 · I have a floating point number, say 135.12345678910. I want to concatenate that value to a string, but only want 135.123456789. With print, I can easily do this by doing something like: print …

  8. ValueError: could not convert string to float: - Stack Overflow

    Jan 3, 2018 · It is obvious that the double quotes cause the problem, Python can only convert a string of numbers (and the decimal symbol) to a float. One way to remove the double-quotes are using a …

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

  10. python - How to convert a string to a number if it has commas in it as ...

    For float values, see How can I convert a string with dot and comma into a float in Python, although the techniques are essentially the same.