import pandas as pd df=pd.read_csv('sales.csv',sep=',') def get_score(x,df,col,is_ascending=True): a= df[col].quantile(0.25) b=df[col].median() c=df[col].quantile(0.75) if is_ascending==True: if x<=a: return('1') if a<x<=b: return('2') ...