I have a dataframe with multiple columns and I want to calculate some averages, however the result is often an inf
value, which is messing up my dataframe. Is it possible to round down the inf
value in Python?
Some example of code:
df['Htgs/2'] = df.groupby('Home Team', ) ['Hg'].rolling(window=a, min_periods=a ).mean().reset_index(0,drop=True)
df['Htgs/2']= (((df['Htgs/2'] * a) - df['Hg']) / (a-1)) / df['Lha']
df['Agcr/2'] = df.groupby('Away Team', ) ['Agcr'].rolling(window=a, min_periods=a ).mean().reset_index(0,drop=True)
df['Agsr/2']= (((df['Agcr/2'] * a) - df['Agcr']) / (a-1))
df = df.round(decimals=3)