Categorical binning in sentiment analysis

Hi everyone,
I want to make bins where values less than zero are negative, more than zero are positive and zero itself is neutral but if I divide them in bins then I can only use two labels. Can anyone tell me how to showcase zero as neutral instead of negative?

bins = [-1, 0, 1]
labels = [“Negative”, “Positive”]
FinalResults[‘Sentiment’] = pd.cut(FinalResults[‘Polarity’], bins=bins, labels=labels)

Hi @siddharth238, You can run a for loop, passing the following conditions:

if value <0 :
label negative

else if vlaue >0:
label positive

else:
label zero

1 Like