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?
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)