df['sentiment_encoded'] = df['sentiment']. apply(lambda x: 0 if x == 'negative' else 1) df.head()