I have the following problem: having a list of values, let's say:
x = [1000, 950, 860, 1120, 430, 270, 0, 15, 0, 26, 278, 0, 950, 1020, 980, 1040, 670, 540, 820, 0, 0, 0, 190, 270, 479, 1247]
I calculate the mean val:
mean = np.mean(x)
# 505.96
Now I would like to calculate a list, where a value is assigned (starting from 1) to each item of list x, that if the item is higher than mean, then it assigns one (same) value until the relation its shifted (lower than mean), then it assigns the second val, and so on. So for the example x list, the output is as follows:
x = [1000, 950, 860, 1120, 430, 270, 0, 15, 0, 26, 278, 0, 950, 1020, 980, 1040, 670, 540, 820, 0, 0, 0, 190, 270, 479, 1247]
# [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5 ]
Thanks