pandas convert inf to nan code example
Example 1: python pandas convert nan to 0
pandas.DataFrame.fillna(0)
Example 2: pandas dataframe replace inf
df.replace([np.inf, -np.inf], np.nan)
Example 3: check if dataframe contains infinity
df.replace([np.inf, -np.inf], np.nan).dropna(subset=["col1", "col2"], how="all")
Example 4: pandas dataframe convert nan to string
df.fillna('', inplace=True)