a = np.random.randint(15, 37, (2, 3, 4))
print(a)
[[[33 22 16 29]
[28 36 36 23]
[15 26 27 24]]
[[17 26 36 31]
[28 20 33 32]
[22 30 19 31]]]
b = np.full_like(a.astype(str), 'medium')
b[a < 20] = 'small'
b[a > 30] = 'large'
print(b)
[[['large' 'medium' 'small' 'medium']
['medium' 'large' 'large' 'medium']
['small' 'medium' 'medium' 'medium']]
[['small' 'medium' 'large' 'large']
['medium' 'medium' 'large' 'large']
['medium' 'medium' 'small' 'large']]]