how to fill inifinity with 0 pandas code example Example: pandas dataframe replace inf df.replace([np.inf, -np.inf], np.nan)