Skip to content
Advertisement

Converting exponential number from string to float (encoding issue?) Python

I want to calculate with a value in my dataframe, however, this string consists of an exponential number (’10⁻³’). Is this some kind of encoding issue? How can I convert this string into a float (e.g. 10e-3) so that can perform calculations with this value?

(using Python 3.8.8)

Advertisement

Answer

First problem is to convert the Unicode symbols to something easier to work with.

JavaScript

Now you can put an ‘e’ in front of any ‘-‘ or ‘+’:

JavaScript

Now you have a format you can give to float.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement