pandas check for inf code example
Example 1: python check if is pandas dataframe
import pandas as pd
isinstance(df, pd.DataFrame)
Example 2: check if dataframe contains infinity
df.replace([np.inf, -np.inf], np.nan).dropna(subset=["col1", "col2"], how="all")
Example 3: pandas dataframe replace inf
df.replace([np.inf, -np.inf], np.nan)
Example 4: check if value is in series pandas
In [21]: s.unique()
Out[21]: array(['a', 'b', 'c'], dtype=object)
In [22]: 'a' in s.unique()
Out[22]: True