↓ Skip to main content
All methods

pandas.Series.as_float

Series method → Series
Signature
Series.as_float()

Convert fractional odds from fraction strings to floating point.

This is the reverse of Series.as_fraction. Use it to read fractional odds such as '5/2' before passing them to other stakepd methods with odds_type='fractional'.

Returns

pandas.Series
Fractional odds as float values.

See also

pandas.Series.as_fraction
The reverse: floating point to fraction strings.
pandas.Series.implied_probability
Calculate the implied probability from a Series of odds.

Examples
#

import pandas as pd
import stakepd as spd   # importing stakepd adds these methods to pandas objects

Example:

fractional_strings = pd.Series(["1/4", "1/2", "2/1"])
fraction_odds = fractional_strings.as_float()
print(fraction_odds)
Output:
0    0.25
1    0.50
2    2.00
dtype: float64

This method is also covered, alongside the rest of the module, in the overview guide.