I have two series (prior & new) with z rows in both & values from 0 to 5 and would like to assign into buckets based on the impact from switching from the old to the new list. I normally use list comprehension for x in y statements for this type of operation, but now I would like to apply my condition on two variables at the same time.
I tried using the line below:
buckets = ['5) +10%' if x <= 1 and y == 3 else '4) +5%' if x == 2 and y == 3 else \
'4) +5%' if x <= 1 and y == 2 else '2) -5%' if x == 3 and y == 2 else \
'1) -10%' if x == 3 and y <= 1 else '2) -5%' if x == 2 and y <= 1 else \
'3) 0%' for x in prior for y in new]
This produces a list with z*z rows while I would like to only have a list with z rows. So anyway to use list comprehension like this without getting into a Cartesian product?