Store | Sales Amount | Profit |
---|---|---|
27 | 75474 | 9253 |
30 | 367852 | 84463 |
55 | 79416 | 15401 |
The resulting output should contain pairs of rows which has sales amount +- 3% OR Profit +- 1.5 % of each other
like if store 55's Sales amount fall within the range of +- 3% of sales amount OR +- 1.5 % of profit of any store(lets say 27) the output should be :
| Output|
27-55
df['Lower_range_sales'] = df['Sales_amount'] - df['Sales_amount']*0.03
df['Upper_range_sales'] = df['Sales_amount'] + df['Sales_amount']*0.03
df['Lower_range_Profit'] = df['Profit'] - df['Profit']*0.015
df['Upper_range_Profit'] = df['Profit'] + df['Profit']*0.015
Let's call stores that meet your condition "within range" of each other. There are no such store in your sample data set so we need to mock it with some randomized data:
Result: