I have an array which represents some time series data:
array([[[-0.59776013],
[-0.59776013],
[-0.59776013],
[-0.31863936],
[-0.31863936],
[-0.31863936],
[-0.31863936],
[-0.31863936],
[-0.31863936],
[ 0.31863936],
[ 0.31863936],
[ 0.31863936],
[-0.31863936],
[-0.31863936],
[-0.31863936],
[-0.31863936],
[-0.31863936],
[-0.31863936],
[ 0.59776013],
[ 0.59776013],
[ 0.59776013],
[ 0.93458929],
[ 0.93458929],
[ 0.93458929],
[-0.31863936],
[-0.31863936],
[-0.31863936],
[-0.31863936],
[-0.31863936],
[-0.31863936],
[-0.06270678],
[-0.06270678],
[-0.06270678],
[-0.06270678],
[-0.06270678],
[-0.06270678],
[-0.31863936],
[-0.31863936],
[-0.31863936],
[-0.31863936],
[-0.31863936],
[-0.31863936],
[ 0.75541503],
[ 0.75541503],
[ 0.75541503],
[ 0.93458929],
[ 0.93458929],
[ 0.93458929],
[-0.31863936],
[-0.31863936],
[-0.31863936],
[ 0.75541503],
[ 0.75541503],
[ 0.75541503],
[-0.31863936],
[-0.31863936],
[-0.31863936],
[ 0.31863936],
[ 0.31863936],
[ 0.31863936],
[ 0. ],
[ 0. ],
[ 0. ],
[ 0. ],
[ 0. ],
[ 0. ],
[ 0. ],
[ 0. ]]])
The unique values in this array are:
np.unique(sax_dataset_inv)
array([-0.59776013, -0.31863936, -0.06270678, 0. , 0.31863936,
0.59776013, 0.75541503, 0.93458929])
My task
Assign either 'F' for fast, 'S' for slow or 'M' for medium to a given array value.
My attempt
I can do it for 2 assignments, 'F' or 'S':
sax_list = ['F' if element < 0 else 'S' for element in list(sax_dataset_inv.flatten())]
However I cannot understand how I can do the same expression above for 3 different labels.
Desired Output
Take an example array of [-3-2-1,0,1,2,3,4,5,6]
The values -3 to -1 inclusive should be assigned 'F'. Values 0 to 3 inclusive should be assigned 'M'. Values greater than 3 should be assigned 'S'.