""" create some test-data """
random_data = np.random.random([3, 3])
random_data[0, 0] = 0.0
random_data[1, 2] = 0.0
df = pd.DataFrame(random_data, columns=['A', 'B', 'C'], index=['first',
    'second', 'third'])
print(df)
""" binarize """
threshold = lambda x: x > 0
df_ = df.apply(threshold).astype(int)
print(df_)
Binarize a float64 Pandas Dataframe in Python