replace()
returns a new object (so assign it or use inplace=True
), your types must match (0
vs '0'
), and your mapping with duplicate 'polarity'
keys overwrote itself.
Use this:
sentiment_text['polarity'] = sentiment_text['polarity'].replace({0: 'negative', 4: 'positive'})