What about passing a proper list of keys ['X', 'Y', 'Z'] to your dataframe instead of a long string 'X, Y, Z':
import numpy as np
import pandas as pd
data = {'X': np.linspace(0,2,8), 'Y': np.linspace(0,2,8)*2, 'Z': np.linspace(0,2,8)*4}
df = pd.DataFrame.from_dict(data)
which gives:
>>> df
>>> 0 0.000000 0.000000 0.000000
>>> 1 0.285714 0.571429 1.142857
>>> 2 0.571429 1.142857 2.285714
>>> 3 0.857143 1.714286 3.428571
>>> 4 1.142857 2.285714 4.571429
>>> 5 1.428571 2.857143 5.714286
>>> 6 1.714286 3.428571 6.857143
>>> 7 2.000000 4.000000 8.0000000
df[['X', 'Y', 'Z']] = np.where(df[['X', 'Y', 'Z']] < 1, 0, df[['X', 'Y', 'Z']])
and now with no longer KeyError:
>>> df
>>> 0 0.000000 0.000000 0.000000
>>> 1 0.000000 0.000000 1.142857
>>> 2 0.000000 1.142857 2.285714
>>> 3 0.000000 1.714286 3.428571
>>> 4 1.142857 2.285714 4.571429
>>> 5 1.428571 2.857143 5.714286
>>> 6 1.714286 3.428571 6.857143
>>> 7 2.000000 4.000000 8.000000