import numpy as np
x = np.array([2, 7, 12, 20, 30])
conditions = [x < 5, x < 15, x <= 20]
choices = ["small", "medium", "large"]
labels = np.select(conditions, choices, default="a real giant")
labelsarray(['small', 'medium', 'medium', 'large', 'a real giant'], dtype='<U12')