May-03-2023, 03:07 AM
Hi all,
I want to compare with the limit and assign different text colors as below two functions.
How to merge two functions(compared_Sens & compared_Noise) to one function apply to all different limits?
I want to compare with the limit and assign different text colors as below two functions.
How to merge two functions(compared_Sens & compared_Noise) to one function apply to all different limits?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
import pandas as pd import numpy as np sens_delta_check = [ - 0.07 , - 0.13 , - 0.16 , - 0.08 , - 0.11 , - 0.12 , - 0.04 , - 0.06 , - 0.08 , - 0.03 , 0 , 0 , - 0.05 , - 0.01 , - 0.01 , - 0.11 , - 0.05 , - 0.08 , - 0.04 , - 0.06 , 0.01 , - 0.17 , - 0.07 , - 0.06 , - 0.14 , - 0.07 , - 0.1 , - 0.05 , 0.03 , - 0.1 , - 0.05 , - 0.1 , - 0.15 , 0.02 , - 0.03 ] noise_check = [ - 104.09 , - 103.99 , - 104.09 , - 103.87 , - 104.05 , - 104 , - 103.98 , - 103.97 , - 103.93 , - 103.99 , - 103.93 , - 104.01 , - 103.98 , - 103.97 , - 103.86 , - 103.93 , - 104.02 , - 104.1 , - 103.97 , - 103.96 , - 104 , - 103.94 , - 104.01 , - 104 , - 103.95 , - 103.99 , - 103.97 , - 103.97 , - 103.99 , - 104 , - 104.04 , - 103.97 , - 103.96 , - 103.95 , - 103.95 ] def compared_Sens(val,limit1,limit2,limit3): # 0.3,0.2,0.1 if np. abs (val)>limit1: text_color = 'Dark Red' elif np. abs (val)>limit2: text_color = 'Red' elif np. abs (val)>limit3: text_color = 'orange' elif pd.isnull(val): text_color = 'White' else : text_color = 'Green' return text_color def compared_Noise(val,limit1,limit2,limit3): # 103.2,102.5,102 if np. abs (val)>limit1: text_color = 'green' elif np. abs (val)>limit2: text_color = 'orange' elif np. abs (val)>limit3: text_color = 'red' elif pd.isnull(val): text_color = 'White' else : text_color = 'dark red' return text_color print (compared_Sens(sens_delta_check, 0.3 , 0.2 , 0.1 ) print (compared_Noise(noise_check, 103.2 , 102.5 , 102 ) |