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