I have the following dataframe df:
print(df) Food Taste 0 Apple NaN 1 Banana NaN 2 Candy NaN 3 Milk NaN 4
I prefer to use .loc in such cases, and explicitly use the index of the DataFrame if you want to select on position:
.loc
df.loc[df.index[0:2], 'Taste'] = 'good' df.loc[df.index[2:6], 'Taste'] = 'bad'