I have a large dataframe with inf, -inf values in different columns. I want to replace all inf, -inf values with NaN
I can do so column by column. So this works:
df['column name'] = df['column name'].replace(np.inf, np.nan)
But my code to do so in one go across the dataframe does not.
df.replace([np.inf, -np.inf], np.nan)
The output does not replace the inf values