data = io.StringIO("""word1 word2 word3
0.0   0.3   1.0
0.1   0.0   0.5
""")
df = pd.read_csv(data, delim_whitespace=True)
res = df.astype(bool).astype(int)
print(res)
Binarize a float64 Pandas Dataframe in Python