import numpy as np
df['Y'] = np.where(df['X'].ge(5),1,df['Y'])
df['Y'] = np.where(df['X'].le(-5),0,df['Y'])
Even better, for multiple conditions, use np.select:
conditions=[df['X'].ge(5),df['X'].le(-5)]
choices=[1,0]
df['Y']=np.select(conditions,choices,default=df['Y'])
Or, if you only want to do it with a list comprehension, use zip:
df['Y'] =[1 if x>=5 else(0 if x<=-5 else y)for x,y in zip(df['X'],df['Y'])]