So I have a dataframe:
import pandas as pd df = pd.DataFrame({\'name\': [\'Jason\', \'Molly\', \'Tina\', \'Jake\', \'Amy\'], \'score\': [1, 3, 4, 5, 2]
Using pd.cut
pd.cut(df.score,[0,2,4,np.Inf],labels=['sad','ok','happy']) Out[594]: 0 sad 1 ok 2 ok 3 happy 4 sad #df['yourcol']=pd.cut(df.score,[0,2,4,np.Inf],labels=['sad','ok','happy'])