In [1]:
import pandas as pd
In [2]:
df = pd.DataFrame({'col_1': [1, 0, 1, None],
'col_2': [1.2, 3.1, 4.4, 5.5],
'col_3': [1, 2, 3, 4],
'col_4': ['a', 'b', 'c', 'd']})
In [3]:
df
Out[3]:
In [4]:
bool_cols = [col for col in df if len(df[[col]].dropna()[col].unique()) == 2]
In [5]:
bool_cols
Out[5]:
In [6]:
df[bool_cols]
Out[6]:
In [ ]: