df = pd.DataFrame({'X': [1, 2, 3,],
'Y': [4, 1, 8]})
# X Y
# 0 1 4
# 1 2 1
# 2 3 8
tmp_df = df[(df['X'] == 1) & (df['Y'].notnull())]
# X Y
# 1 2 1
df = pd.DataFrame({'X': [1, 2, 3,],
'Y': [4, 1, 8]})
for i in df[(df['X'] == 1) & (df['Y'].notnull())].index:
df.at[i, 'Y'] = 9
print(df)
# X Y
# 0 1 4
# 1 2 9
# 2 3 8