how to find infinite number pandas code example Example: pandas dataframe replace inf df.replace([np.inf, -np.inf], np.nan)