Skip to content
Advertisement

Is there a quick way in python to convert a string ‘1/100’ to float 0.01?

I have this df:

JavaScript

which I would like to convert to decimal odds.

I know i could use .split('/') to achieve this but was wondering if there was a quicker way to do this.

Advertisement

Answer

As suggested by @ch3steR, use pd.eval and try this

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