↓ Skip to main content
All methods

pandas.DataFrame.convert

DataFrame method → DataFrame
Signature
DataFrame.convert(from_type, to_type)

Convert a DataFrame between odds types, or between odds and implied probability.

Parameters

from_type:{'decimal', 'fractional', 'american', 'implied_probability'}
Format of the values in the DataFrame.
to_type:{'decimal', 'fractional', 'american', 'implied_probability'}
Format to convert to.

Returns

pandas.DataFrame
Odds or implied probabilities as float values in to_type format.

See also

pandas.Series.convert
Convert a Series between odds types, or between odds and implied probability.
pandas.DataFrame.implied_probability
Calculate the implied probability from a DataFrame of odds.
pandas.DataFrame.odds
Convert a DataFrame of implied probabilities to the specified odds type.

Examples
#

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

Decimal to American:

decimal_odds = pd.DataFrame({"A": [2.0, 1.5, 5.0], "B": [50, 8.0, 25.0]})
american_odds = decimal_odds.convert(from_type="decimal", to_type="american")
print(american_odds)
Output:
   A_implied_probability_american_odds  B_implied_probability_american_odds
0                                100.0                               4900.0
1                               -200.0                                700.0
2                                400.0                               2400.0

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